<?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: how to change the number formatting to 2 decimals  and multiply with 1000 for all fields except the fields with stri in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-the-number-formatting-to-2-decimals-and-multiply/m-p/597851#M208181</link>
    <description>&lt;P&gt;The fieldformat syntax is almost the same as eval. The difference is that fieldformat doesn't create a new field as such. So you will see the "field" in output but you cannot calculate anything based on its value - you have to use the original field.&lt;/P&gt;&lt;P&gt;See the example (also shows the difference between eval and fieldformat):&lt;/P&gt;&lt;PRE&gt;| makeresults count=210&lt;BR /&gt;| streamstats count&lt;BR /&gt;| eval part=count/13&lt;BR /&gt;| eval truncated=round(part,1)&lt;BR /&gt;| fieldformat formatted=round(part,1)&lt;BR /&gt;| eventstats sum(truncated) as truncatedsum sum(part) as partsum&lt;/PRE&gt;&lt;P&gt;In case of simple multiplying when there's no rounding error, there's not much of a practical difference since the value itself does not differ but in case of fractions the error can accumulate and skew the final results.&lt;/P&gt;&lt;P&gt;The most useful use case of field format is with timestamp manipulation when you leave the original timestamp field in numerical form which allows for easy adding/substracting intervals and so on but still can get a human-readable representation in the results.&lt;/P&gt;</description>
    <pubDate>Sat, 14 May 2022 07:25:18 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2022-05-14T07:25:18Z</dc:date>
    <item>
      <title>How to change the number formatting to 2 decimals  and multiply with 1000 for all fields except the fields with strings?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-the-number-formatting-to-2-decimals-and-multiply/m-p/597550#M208046</link>
      <description>&lt;TABLE border="0" width="448" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64" height="20"&gt;a&lt;/TD&gt;
&lt;TD width="64"&gt;b&lt;/TD&gt;
&lt;TD width="64"&gt;c&lt;/TD&gt;
&lt;TD width="64"&gt;d&lt;/TD&gt;
&lt;TD width="64"&gt;e&lt;/TD&gt;
&lt;TD width="64"&gt;f&lt;/TD&gt;
&lt;TD width="64"&gt;g&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="20"&gt;xyz&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;5&lt;/TD&gt;
&lt;TD&gt;6&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My table&amp;nbsp; looks like that&lt;BR /&gt;I need the following table&lt;/P&gt;
&lt;TABLE border="0" width="472px" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="40px" height="20"&gt;a&lt;/TD&gt;
&lt;TD width="72px"&gt;b&lt;/TD&gt;
&lt;TD width="72px"&gt;c&lt;/TD&gt;
&lt;TD width="72px"&gt;d&lt;/TD&gt;
&lt;TD width="72px"&gt;e&lt;/TD&gt;
&lt;TD width="72px"&gt;f&lt;/TD&gt;
&lt;TD width="72px"&gt;g&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="40px" height="20"&gt;xyz&lt;/TD&gt;
&lt;TD width="72px"&gt;1000.00&lt;/TD&gt;
&lt;TD width="72px"&gt;2000.00&lt;/TD&gt;
&lt;TD width="72px"&gt;3000.00&lt;/TD&gt;
&lt;TD width="72px"&gt;4000.00&lt;/TD&gt;
&lt;TD width="72px"&gt;5000.00&lt;/TD&gt;
&lt;TD width="72px"&gt;6000.00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="40px" height="20"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="72px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="72px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="72px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="72px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="72px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="72px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but with the below command I am getting the following table :&lt;BR /&gt;my string field gets eliminated&lt;/P&gt;
&lt;P&gt;&lt;FONT face="andale mono,times" color="#FF9900"&gt;my query for data&amp;nbsp;| foreach * [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = round(('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;' * 1000),2) ]&lt;/FONT&gt;&lt;/P&gt;
&lt;TABLE border="0" width="496px" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="63.0625px" height="15px"&gt;a&lt;/TD&gt;
&lt;TD width="71.9844px" height="15px"&gt;b&lt;/TD&gt;
&lt;TD width="71.9844px" height="15px"&gt;c&lt;/TD&gt;
&lt;TD width="71.9844px" height="15px"&gt;d&lt;/TD&gt;
&lt;TD width="71.9844px" height="15px"&gt;e&lt;/TD&gt;
&lt;TD width="71.9844px" height="15px"&gt;f&lt;/TD&gt;
&lt;TD width="72.0156px" height="15px"&gt;g&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="63.0625px" height="15px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="71.9844px" height="15px"&gt;1000.00&lt;/TD&gt;
&lt;TD width="71.9844px" height="15px"&gt;2000.00&lt;/TD&gt;
&lt;TD width="71.9844px" height="15px"&gt;3000.00&lt;/TD&gt;
&lt;TD width="71.9844px" height="15px"&gt;4000.00&lt;/TD&gt;
&lt;TD width="71.9844px" height="15px"&gt;5000.00&lt;/TD&gt;
&lt;TD width="72.0156px" height="15px"&gt;6000.00&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to obtain everything&amp;nbsp; above along&amp;nbsp; with xyz in a column ?&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 15:42:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-the-number-formatting-to-2-decimals-and-multiply/m-p/597550#M208046</guid>
      <dc:creator>paritoshs24</dc:creator>
      <dc:date>2022-05-13T15:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the number formatting to 2 decimals  and multiply with 1000 for all fields except the fields with stri</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-the-number-formatting-to-2-decimals-and-multiply/m-p/597559#M208052</link>
      <description>&lt;P&gt;Firstly, I'm not a big fan of truncating fields or modifying them in any way without a good cause so I'd rather use fieldformat rather than eval (especially if you want to calculate something down the processing stream based on the original values; truncating introduces rounding error).&lt;/P&gt;&lt;P&gt;But I'm digressing.&lt;/P&gt;&lt;P&gt;The easiest thing to do is use coalesce to add the original value in case your computations turned null.&lt;/P&gt;&lt;PRE&gt;eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = coalesce(round('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'*1000,2),'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')&lt;/PRE&gt;&lt;P&gt;As coalesce() evaluates to the first non-null value from the list, for numerical values you'll get your number, for other values you'll get the original field contents.&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 10:13:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-the-number-formatting-to-2-decimals-and-multiply/m-p/597559#M208052</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-05-12T10:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the number formatting to 2 decimals  and multiply with 1000 for all fields except the fields with stri</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-the-number-formatting-to-2-decimals-and-multiply/m-p/597696#M208104</link>
      <description>&lt;P&gt;Thanks for the solution.&lt;BR /&gt;&lt;BR /&gt;Can you also please provide the solution with FEILDFORMAT command ? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 22:01:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-the-number-formatting-to-2-decimals-and-multiply/m-p/597696#M208104</guid>
      <dc:creator>paritoshs24</dc:creator>
      <dc:date>2022-05-12T22:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the number formatting to 2 decimals  and multiply with 1000 for all fields except the fields with stri</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-the-number-formatting-to-2-decimals-and-multiply/m-p/597716#M208119</link>
      <description>&lt;P&gt;The coalesce command isn't working, its printing all the values as it is&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 05:54:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-the-number-formatting-to-2-decimals-and-multiply/m-p/597716#M208119</guid>
      <dc:creator>paritoshs24</dc:creator>
      <dc:date>2022-05-13T05:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the number formatting to 2 decimals  and multiply with 1000 for all fields except the fields with stri</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-the-number-formatting-to-2-decimals-and-multiply/m-p/597735#M208135</link>
      <description>&lt;P&gt;Works for me.&lt;/P&gt;&lt;P&gt;See this runanywhere example:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PickleRick_0-1652427830629.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/19628i7D9441145F0D383A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PickleRick_0-1652427830629.png" alt="PickleRick_0-1652427830629.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 07:44:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-the-number-formatting-to-2-decimals-and-multiply/m-p/597735#M208135</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-05-13T07:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the number formatting to 2 decimals  and multiply with 1000 for all fields except the fields with stri</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-the-number-formatting-to-2-decimals-and-multiply/m-p/597797#M208165</link>
      <description>&lt;P&gt;Sorry, My Bad !!&amp;nbsp;&lt;BR /&gt;Worked for me&amp;nbsp; too, it was an error on my part.&lt;/P&gt;&lt;P&gt;Can you also&amp;nbsp; please provide me a solution with field formatting, will keep that in mind for future use cases.&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 16:10:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-the-number-formatting-to-2-decimals-and-multiply/m-p/597797#M208165</guid>
      <dc:creator>paritoshs24</dc:creator>
      <dc:date>2022-05-13T16:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the number formatting to 2 decimals  and multiply with 1000 for all fields except the fields with stri</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-the-number-formatting-to-2-decimals-and-multiply/m-p/597851#M208181</link>
      <description>&lt;P&gt;The fieldformat syntax is almost the same as eval. The difference is that fieldformat doesn't create a new field as such. So you will see the "field" in output but you cannot calculate anything based on its value - you have to use the original field.&lt;/P&gt;&lt;P&gt;See the example (also shows the difference between eval and fieldformat):&lt;/P&gt;&lt;PRE&gt;| makeresults count=210&lt;BR /&gt;| streamstats count&lt;BR /&gt;| eval part=count/13&lt;BR /&gt;| eval truncated=round(part,1)&lt;BR /&gt;| fieldformat formatted=round(part,1)&lt;BR /&gt;| eventstats sum(truncated) as truncatedsum sum(part) as partsum&lt;/PRE&gt;&lt;P&gt;In case of simple multiplying when there's no rounding error, there's not much of a practical difference since the value itself does not differ but in case of fractions the error can accumulate and skew the final results.&lt;/P&gt;&lt;P&gt;The most useful use case of field format is with timestamp manipulation when you leave the original timestamp field in numerical form which allows for easy adding/substracting intervals and so on but still can get a human-readable representation in the results.&lt;/P&gt;</description>
      <pubDate>Sat, 14 May 2022 07:25:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-the-number-formatting-to-2-decimals-and-multiply/m-p/597851#M208181</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-05-14T07:25:18Z</dc:date>
    </item>
  </channel>
</rss>

