Splunk Search

How to calculate with multiple values in a table?

dailv1808
Path Finder

I have few results which look like below in a table:

ID         Ask        Bid
1   |      4     |    3
2   |      5     |    6
3   |      7     |    8

I want to create new field with newfield=(4*6-8)/8
So how do I it?
All suggestions are welcome.

0 Karma
1 Solution

Sukisen1981
Champion

| sort ID
| streamstats count as row
| eval x= If(row=2,Bid,0)
| eval y= If(row=3,Bid,0)
| eval z= If(row=1,Ask,0)
| eval t=x+y+z
| streamstats current=false last(t) as prevt
| eval z1=case(row=2,t*prevt)
| streamstats current=false last(z1) as prevz1
| eval final=(prevz1-t)/t
| eventstats max(final) as net
| eval net=if(row=1,net,0)
| table ID,Ask,Bid,net

If you want to display net in ALL rows remove the final eval statement

View solution in original post

0 Karma

niketn
Legend

@dailv1808, what is the correlation/logic for picking up (4*6-8)/8?
Did you mean (3*6-8)/8, which are the values in Bid field?
Please elaborate for us to assist you better.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

dailv1808
Path Finder

thank for your respond.
Yes. 6 and 8 are values in Bid field.
4 value in Ask field

0 Karma

niketn
Legend

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?

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

dailv1808
Path Finder

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

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...