Amit
Amit

Reputation: 11

Kusto Distinct Count

I have written two queries below to extract distinct count/record from a table. However, both of them are giving me different results.

The first query returns more records than the second query.

query 1:

.ReachOptimization_L0
| where CurrentSubscriptionStatus == "ACTIVE"| where SnapshotDate =="2019-11-29"| where IsOptIn==1| where CampaignName != ""  or CampaignId != ""| where ReachedFlag== 1| summarize dcount(UserPUID)

query 2:

.ReachOptimization_L0| where CurrentSubscriptionStatus == "ACTIVE"| where SnapshotDate =="2019-11-29"| where IsOptIn==1| where CampaignName != ""  or CampaignId != ""| where ReachedFlag== 1| distinct UserPUID

Upvotes: 1

Views: 17742

Answers (1)

Alexander Sloutsky
Alexander Sloutsky

Reputation: 3017

dcount() aggregation function is an estimation of distinct count as outlined in https://learn.microsoft.com/en-us/azure/kusto/query/dcount-aggfunction

"Returns an estimate for the number of distinct values taken by a scalar expression in the summary group."

The estimation accuracy can be found on the same page: https://learn.microsoft.com/en-us/azure/kusto/query/dcount-aggfunction#estimation-accuracy

Upvotes: 5

Related Questions