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.
| 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
@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.
thank for your respond.
Yes. 6 and 8 are values in Bid field.
4 value in Ask field
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?
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