I have a result set that I want to display in a table, but customize the header names. My search uses append to get 2 sets of values, and then merges them using stats
search ... | stats dc(VisitorID) as "visitors" by Ranges | append [
search ... | stats dc(VisitorID) as "VisitorsWhoX" by Ranges
]
Gives:
Ranges visitors VisitorsWhoX
0-10 11
11-20 19
21-30 7
0-10 6
11-20 9
21-30 2
From this point, I want to do 3 things: Merge the 2 searches by range, calc a 3rd column and rename the column headers. So I do the following:
... | stats last(visitors) as visitors last(VisitorsWhoX) as VisitorsWhoX by Ranges
| eval "Conversion Rate"=round(VisitorsWhoX / visitors * 100)."%"
| eval "# of Visitors"=visitors | eval "Visitors who X"=VisitorsWhoX | table Ranges "# of Visitors" "Visitors who X" Ranges
Using this method does give me the results I work, just wondering if it can be optimized:
stats
in the first line above?| eval "New Field"=oldfield"
commands seems very inefficient.appendcols
to add the fields to your main search and then include them in the table that way?rename
? Then you could do something like (for example):..|rename visitors as "# of Visitors", VisitorsWhoX as "Visitors who X" |..
appendcols
to add the fields to your main search and then include them in the table that way?rename
? Then you could do something like (for example):..|rename visitors as "# of Visitors", VisitorsWhoX as "Visitors who X" |..
appendcols doesn't work because there isn't a 1 to 1 mapping of columns. in the example above, "VisitorsWhoX" may be null for 0-10 (I could set to 0 if isnull though).
rename: perfect. thank you.
excellent. worked for me