Hello everyone,
I have a table (generated from stats) that has several columns, and some values of those columns have "X's". I would like to count those X's and total them in the last column of the table. How would I go about doing that?
Here is an example table, and thank you!
Field1 | Field2 | Field3 | Field4 | Field5 | Total_Xs
X | X | Foo | Bar | X | 3
Foo2 | X | Foo | Bar | X | 2
X | X | X | Bar | X | 4
The foreach command can do that.
<<your search>>
| eval Total_Xs = 0
| foreach *
[| eval Total_Xs=Total_Xs + if('<<FIELD>>'="X", 1, 0)]
Thank you for the response!
So, I tried it, and it isn't working, but for more context:
I run a stats command for the table, and after that, I run a fillnull to insert the X's into the table. I tried another stats after that, but that didn't work.
How would I append the "Total_X's" field to the table?
Please elaborate on "it isn't working". That doesn't give us anything to work with. Show us what you get so we can offer other suggestions.
Use the eval command to add a field to the results table.