<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Can I use modulus in Splunk to extract the decimal portion (only) of a result? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368042#M166433</link>
    <description>&lt;P&gt;@DalJeanis, I need to take not just Splunk lessons from you but maths also &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;How about dividend &amp;lt; divisor? like (3/7)?&lt;/P&gt;</description>
    <pubDate>Mon, 14 Aug 2017 02:40:35 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-08-14T02:40:35Z</dc:date>
    <item>
      <title>Can I use modulus in Splunk to extract the decimal portion (only) of a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368036#M166427</link>
      <description>&lt;P&gt;how to extract only decimal values in splunk ? ..example  (7 divided by 2 ) = 3.5 , I need to get only 0.5 here ...will "%" work (or) is there any MOD funciton to accomplish this task ?&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2017 22:40:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368036#M166427</guid>
      <dc:creator>nittalasub</dc:creator>
      <dc:date>2017-08-12T22:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use modulus in Splunk to extract the decimal portion (only) of a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368037#M166428</link>
      <description>&lt;P&gt;Splunk does support the modulus (%) operator.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2017 23:04:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368037#M166428</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-08-12T23:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use modulus in Splunk to extract the decimal portion (only) of a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368038#M166429</link>
      <description>&lt;P&gt;So it would look like this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... | eval remainder=7%2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Correct?  I've never done it before.&lt;/P&gt;</description>
      <pubDate>Sun, 13 Aug 2017 03:08:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368038#M166429</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-08-13T03:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use modulus in Splunk to extract the decimal portion (only) of a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368039#M166430</link>
      <description>&lt;P&gt;Following is the run anywhere search. While modular division is possible, you are actually looking just to extract decimal places.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval dividend=7
| eval divisor=2
| eval value=dividend/divisor
| eval remainder=dividend%divisor
| eval quotient=replace(value,"(\d+).(\d+)","\1")
| eval decimal=replace(value,"(\d+)(\.\d+)","0\2")
| table dividend divisor value remainder quotient decimal
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following are the results:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;dividend    divisor value   remainder   quotient    decimal
7          2          3.5     1         3          0.5
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 13 Aug 2017 05:18:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368039#M166430</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-08-13T05:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use modulus in Splunk to extract the decimal portion (only) of a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368040#M166431</link>
      <description>&lt;P&gt;@jkat54 - correct, but one more step to get the requested answer...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  ... | eval decimal=(7%2)/2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 13 Aug 2017 20:38:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368040#M166431</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-08-13T20:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use modulus in Splunk to extract the decimal portion (only) of a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368041#M166432</link>
      <description>&lt;P&gt;@niketnilay - Great demo, but modulo arithmetic does simplify the calculation down to .. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  ... | eval decimal=(7%2)/2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 13 Aug 2017 20:40:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368041#M166432</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-08-13T20:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use modulus in Splunk to extract the decimal portion (only) of a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368042#M166433</link>
      <description>&lt;P&gt;@DalJeanis, I need to take not just Splunk lessons from you but maths also &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;How about dividend &amp;lt; divisor? like (3/7)?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2017 02:40:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368042#M166433</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-08-14T02:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use modulus in Splunk to extract the decimal portion (only) of a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368043#M166434</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;3%7 is 3, so (3%7)/7 = 3/7
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The formula only fails (potentially)for negative numbers.  &lt;/P&gt;

&lt;P&gt;Depending on implementation  -3%7 can be considered to be either -3 or +4.  Those two numbers are identities in mod 7 ring theory and whatever the other relevant branches of discrete math are.... but not when you are calculating real world stuff. &lt;/P&gt;

&lt;P&gt;So, for safety, if I couldn't run a quick test, I'd end up coding that as... &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   decimal=round(if(X&amp;lt;0, -(-X%Y)/Y,(X%Y)/Y),somenumber)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Aug 2017 03:19:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368043#M166434</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-08-14T03:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use modulus in Splunk to extract the decimal portion (only) of a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368044#M166435</link>
      <description>&lt;P&gt;@Daljeanis -- thank you so much ! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;  that helped me to extract decimals from floating point numbers.&lt;/P&gt;

&lt;P&gt;special thanks to Nike !&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2017 05:12:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368044#M166435</guid>
      <dc:creator>nittalasub</dc:creator>
      <dc:date>2017-08-14T05:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use modulus in Splunk to extract the decimal portion (only) of a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368045#M166436</link>
      <description>&lt;P&gt;@nittalasub, I have converted @DalJeanis' comment to answer. Please accept to mark this question as answered. Kindly also up vote other comments that helped.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2017 05:49:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-use-modulus-in-Splunk-to-extract-the-decimal-portion-only/m-p/368045#M166436</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-08-14T05:49:03Z</dc:date>
    </item>
  </channel>
</rss>

