<?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 calculate with multiple values in a table? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349303#M103408</link>
    <description>&lt;P&gt;|  sort ID &lt;BR /&gt;
|  streamstats count as row &lt;BR /&gt;
| eval x= If(row=2,Bid,0)&lt;BR /&gt;
| eval y= If(row=3,Bid,0)&lt;BR /&gt;
| eval z= If(row=1,Ask,0)&lt;BR /&gt;
| eval t=x+y+z&lt;BR /&gt;
| streamstats current=false last(t) as prevt&lt;BR /&gt;
| eval z1=case(row=2,t*prevt)&lt;BR /&gt;
|  streamstats current=false last(z1) as prevz1&lt;BR /&gt;
| eval final=(prevz1-t)/t&lt;BR /&gt;
| eventstats max(final) as net&lt;BR /&gt;
| eval net=if(row=1,net,0)&lt;BR /&gt;
|  table ID,Ask,Bid,net&lt;/P&gt;

&lt;P&gt;If you want to display net in ALL rows remove the final eval statement&lt;/P&gt;</description>
    <pubDate>Tue, 26 Sep 2017 10:10:08 GMT</pubDate>
    <dc:creator>Sukisen1981</dc:creator>
    <dc:date>2017-09-26T10:10:08Z</dc:date>
    <item>
      <title>How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349298#M103403</link>
      <description>&lt;P&gt;I have few results which look like below in a table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ID         Ask        Bid
1   |      4     |    3
2   |      5     |    6
3   |      7     |    8
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to create new field with newfield=(4*6-8)/8&lt;BR /&gt;
So how do I it?&lt;BR /&gt;
All suggestions are welcome.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 08:44:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349298#M103403</guid>
      <dc:creator>dailv1808</dc:creator>
      <dc:date>2017-09-26T08:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349299#M103404</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/180189"&gt;@dailv1808&lt;/a&gt;, what is the correlation/logic for picking up (4*6-8)/8?&lt;BR /&gt;
Did you mean (3*6-8)/8, which are the values in Bid field?&lt;BR /&gt;
Please elaborate for us to assist you better.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:56:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349299#M103404</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T15:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349300#M103405</link>
      <description>&lt;P&gt;thank for your respond.&lt;BR /&gt;
Yes. 6 and 8 are values in Bid field.&lt;BR /&gt;
4 value in Ask field&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 09:00:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349300#M103405</guid>
      <dc:creator>dailv1808</dc:creator>
      <dc:date>2017-09-26T09:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349301#M103406</link>
      <description>&lt;P&gt;Will your table be fixed size i.e. 3*3 and is the logic first value of Ask and 2nd and 3rd value of Bid?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 09:02:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349301#M103406</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-09-26T09:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349302#M103407</link>
      <description>&lt;P&gt;yes, right. as you said.  The table be fixed size 3*3 and the logic first value of Ask and 2nd and 3rd value of Bid&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 09:07:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349302#M103407</guid>
      <dc:creator>dailv1808</dc:creator>
      <dc:date>2017-09-26T09:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349303#M103408</link>
      <description>&lt;P&gt;|  sort ID &lt;BR /&gt;
|  streamstats count as row &lt;BR /&gt;
| eval x= If(row=2,Bid,0)&lt;BR /&gt;
| eval y= If(row=3,Bid,0)&lt;BR /&gt;
| eval z= If(row=1,Ask,0)&lt;BR /&gt;
| eval t=x+y+z&lt;BR /&gt;
| streamstats current=false last(t) as prevt&lt;BR /&gt;
| eval z1=case(row=2,t*prevt)&lt;BR /&gt;
|  streamstats current=false last(z1) as prevz1&lt;BR /&gt;
| eval final=(prevz1-t)/t&lt;BR /&gt;
| eventstats max(final) as net&lt;BR /&gt;
| eval net=if(row=1,net,0)&lt;BR /&gt;
|  table ID,Ask,Bid,net&lt;/P&gt;

&lt;P&gt;If you want to display net in ALL rows remove the final eval statement&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 10:10:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349303#M103408</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2017-09-26T10:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349304#M103409</link>
      <description>&lt;P&gt;I tried but it does not seem to work properly&lt;BR /&gt;
You can see photo below&lt;BR /&gt;
![alt text][1]&lt;/P&gt;

&lt;P&gt;&lt;A href="https://imgur.com/a/ZKdvP"&gt;https://imgur.com/a/ZKdvP&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 10:19:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349304#M103409</guid>
      <dc:creator>dailv1808</dc:creator>
      <dc:date>2017-09-26T10:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349305#M103410</link>
      <description>&lt;P&gt;I think what you expect and what you have descried is perhaps having gaps.&lt;/P&gt;

&lt;P&gt;Are you getting net as 2?&lt;BR /&gt;
sorry your image is not opening up&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 10:25:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349305#M103410</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2017-09-26T10:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349306#M103411</link>
      <description>&lt;P&gt;sorry, because my english is not good.&lt;BR /&gt;
You can see the result of you search command in the image above by link &lt;A href="https://imgur.com/a/ZKdvP"&gt;https://imgur.com/a/ZKdvP&lt;/A&gt;. &lt;BR /&gt;
My expectation is at the net field displaying the result of the operation (4 * 6-8)/8&lt;BR /&gt;
look like&lt;BR /&gt;
ID Ask Bid Net&lt;BR /&gt;
1 | 4 | 3 | 2 &amp;lt;&amp;lt; --- resuilt of (4 * 6-8) / 8&lt;BR /&gt;
2 | 5 | 6 |&lt;BR /&gt;
3 | 7 | 8 |&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 10:37:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349306#M103411</guid>
      <dc:creator>dailv1808</dc:creator>
      <dc:date>2017-09-26T10:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349307#M103412</link>
      <description>&lt;P&gt;can you please replace the last table command with additional fields?&lt;BR /&gt;
|  table ID,Ask,Bid,t,prevt,z1,prevz1,final,net&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 10:47:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349307#M103412</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2017-09-26T10:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349308#M103413</link>
      <description>&lt;P&gt;see my reference screen shot below &amp;amp; please run the new table command as state above.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 10:49:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349308#M103413</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2017-09-26T10:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349309#M103414</link>
      <description>&lt;P&gt;ha  I think I figured out your issue... your row numbers....are they really 1,2  and 3?, can you add something like this and pass the results back?&lt;/P&gt;

&lt;P&gt;| table ID,Ask,Bid,t,prevt,z1,prevz1,final,net,row&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 10:56:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349309#M103414</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2017-09-26T10:56:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349310#M103415</link>
      <description>&lt;P&gt;try this  -&lt;/P&gt;

&lt;P&gt;sourcetype="ask" &lt;BR /&gt;
| sort ID &lt;BR /&gt;
| streamstats count as row &lt;BR /&gt;
| eval p=row%3&lt;BR /&gt;
| eval x= If(((p+1)%3=0),Bid,0) &lt;BR /&gt;
| eval y= If((row%3)=0,Bid,0) &lt;BR /&gt;
| eval z= If(x=0 AND y=0,Ask,0) &lt;BR /&gt;
| eval t=x+y+z &lt;BR /&gt;
| streamstats current=false last(t) as prevt &lt;BR /&gt;
| eval z1=case(x!=0,t*prevt) &lt;BR /&gt;
| streamstats current=false last(z1) as prevz1 &lt;BR /&gt;
| eval final=(prevz1-t)/t &lt;BR /&gt;
| eval net=round(case((row%3)=0,final),2)&lt;BR /&gt;
| table ID,Ask,Bid,net&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 11:40:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349310#M103415</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2017-09-26T11:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349311#M103416</link>
      <description>&lt;P&gt;I tried with this search command but nothing displayed in the net field.&lt;BR /&gt;
see my screenshot: &lt;A href="https://imgur.com/a/ZuOl4"&gt;https://imgur.com/a/ZuOl4&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 11:51:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349311#M103416</guid>
      <dc:creator>dailv1808</dc:creator>
      <dc:date>2017-09-26T11:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349312#M103417</link>
      <description>&lt;P&gt;when i change to "table ID,Ask,Bid,t,prevt,z1,prevz1,final,net,row" then the row field show number 1,2 ,3. Other field t,prevt,z1,prevz1,final,net are not show enything.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 11:54:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349312#M103417</guid>
      <dc:creator>dailv1808</dc:creator>
      <dc:date>2017-09-26T11:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349313#M103418</link>
      <description>&lt;P&gt;Please check out my answer above&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 11:56:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349313#M103418</guid>
      <dc:creator>dailv1808</dc:creator>
      <dc:date>2017-09-26T11:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349314#M103419</link>
      <description>&lt;P&gt;hmmm your fields - results.askprice etc are they in number format? I know it displays as number but sometimes it could be a string having numbers as characters. &lt;BR /&gt;
Also, what is the source of your data, CSV or some log files?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 12:17:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349314#M103419</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2017-09-26T12:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349315#M103420</link>
      <description>&lt;P&gt;i'm sure they are in number format. Because the source of data from Json log file. &lt;/P&gt;

&lt;P&gt;{ [-] &lt;BR /&gt;
&amp;nbsp;&amp;nbsp; message: &lt;BR /&gt;
&amp;nbsp;&amp;nbsp; request: /api/v1/getmarket &lt;BR /&gt;
&amp;nbsp;&amp;nbsp; result: { [-] &lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AskPrice: 0.07598950 &lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BTCVolume: 29.08189407 &lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BidPrice: 0.07590000 &lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BuyOrderCount: 102 &lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Change: -1.68 &lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HighPrice: 0.07998059 &lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LastPrice: 0.07590000 &lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LowPrice: 0.07200000 &lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MarketID: 87 &lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SellOrderCount: 103 &lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TradeCount: 516 &lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Volume: 29.08189407 &lt;BR /&gt;
&amp;nbsp;&amp;nbsp; } &lt;BR /&gt;
&amp;nbsp;&amp;nbsp; success: 1 &lt;BR /&gt;
} &lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 12:51:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349315#M103420</guid>
      <dc:creator>dailv1808</dc:creator>
      <dc:date>2017-09-26T12:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349316#M103421</link>
      <description>&lt;P&gt;I read your search command, but i cann't understand your idea. Could you plz explain them ?&lt;BR /&gt;
I thing with other program languages or in exel, this issue is so easy. But In Splunk, it is so hard for me &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 12:55:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349316#M103421</guid>
      <dc:creator>dailv1808</dc:creator>
      <dc:date>2017-09-26T12:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate with multiple values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349317#M103422</link>
      <description>&lt;P&gt;Hi the fields as it is coming in statistics tab , maybe that is causing the issue...can you try this and replace the ID, ask, bid fields with the correct field names? &lt;/P&gt;

&lt;P&gt;| sort ID &lt;BR /&gt;
|eval results.AskPrice=tonumber(results.AskPrice)&lt;BR /&gt;
| eval results.BidPrice = tonumber(results.BidPrice)...&lt;BR /&gt;
rest of the query as in your screen shot&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 13:19:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-with-multiple-values-in-a-table/m-p/349317#M103422</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2017-09-26T13:19:23Z</dc:date>
    </item>
  </channel>
</rss>

