here is an example of the table.
| X | Y | Z | W | |
| A8 | 2 | |||
| B12 | 7 | 5 | ||
| C14 | 5 | |||
| D24 | 2 | 3 | ||
| Total | 2*8+5*14 | 7*12+2*24 | 3*24 | 5*24 |
What is the SPL (formula or command) for calculating the total number as listed in the table?
Thanks,
It really helped me understand the SPL.
Assuming you have this data in Splunk and the field names are A_ X Y Z W, this examples shows how using your data, which you can copy/paste into a search
| makeresults
| eval _raw="A X Y Z W
A8 2
B12 7 5
C14 5
D24 2 3"
| multikv forceheader=1
| table A_ X Y Z W
``` Above reproduces your table ```
``` Get the multiplier from the first field ```
| rex field=A_ "[A-Z](?<mul>\d+)"
``` Now Multiuply the field value by the multiplier ```
| foreach X Y Z W [ eval <<FIELD>>=<<FIELD>>*mul ]
| fields - mul
``` and create the column totals ```
| addcoltotalsI am assuming your final column total for col W is not correct, but should read 5 * 12?