Reputation: 5
I have two queries that find the total number of distinct occurrences of using the count operator. I want to be able to then display percentage of total distinct occurrences of those faults. So I tried dividing DistinctRB by Distinct Faults to give me a ratio.
let DistinctFaults = materialize (FaultView
|distinct ha, Ba, ga
|count);
let DistinctRB = materialize (FaultView
|where RB =~ "yes"
|distinct ha, Ba,ga
|count);
print FaultRB / DistinctFaults
Upvotes: 0
Views: 957
Reputation: 25895
you could try this (using toscalar()
):
let DistinctFaults = toscalar(
FaultView
| distinct ha, Ba, ga
| count
);
let DistinctRB = toscalar(
FaultView
| where RB =~ "yes"
| distinct ha, Ba, ga
| count
);
print result = FaultRB / DistinctFaults
or, if an estimation of the distinct count (using dcountif()
) is an option:
FaultView
| summarize result = dcountif(strcat_delim("_", ha, Ba, ga), RB =~ "yes") /
dcount(strcat_delim("_", ha, Ba, ga))
Upvotes: 1