I have two separate searches and would like to divide the results of the first by the second.
My first search is, which returns "3":
| set intersect [search source="test1.csv" | table Setting] [search source="test2.csv" | table Setting] | stats count(Setting)
And my second search is, which returns "5":
source="test1.csv" | table Setting| stats count(Setting)
I am looking to combine both searches to get ".6". I know how to do this with a more simple search that doesn't involve the intersection of two sources, but am not familiar with how to do it in this case.
Try this
| set intersect [search source="test1.csv" | table Setting] [search source="test2.csv" | table Setting] | stats count(Setting) as Setting1 | appendcols [search source="test1.csv" | table Setting| stats count(Setting) as Setting2] | eval finalValue = Setting1/Setting2
There are a few ways to solve this. One way is use use append to combine the two results into one result set and then use stats to isolate the data points you want. It is easier if we rename the counts before passing them to stats. I will use that approach below
| set intersect [search source="test1.csv" | table Setting] [search source="test2.csv" | table Setting] | stats count(Setting) as dividend
| append [ search source="test1.csv" | table Setting| stats count(Setting) as divisor ]
| stats max(dividend) as dividend max(divisor) as divisor | eval quotient=dividend/divisor
Try this
source="test1.csv" [search source="test2.csv" | table setting] | stats count(setting) as countCommon | appendcols [search source="test1.csv" | table Setting| stats count(Setting) as countAll] | eval perc=countCommon/countAll
Try this
| set intersect [search source="test1.csv" | table Setting] [search source="test2.csv" | table Setting] | stats count(Setting) as Setting1 | appendcols [search source="test1.csv" | table Setting| stats count(Setting) as Setting2] | eval finalValue = Setting1/Setting2