Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
megane123
Frequent Visitor

COUNT vs DISTINCTCOUNT for coverage calculations

Hi all,

 

I am struggling to work out what I think should be some fairly straightforward DAX and can't find anything in the forum. Apologies if I have missed another post.

 

I have a client and product columns. What I am trying to achieve is to calculate what 'client coverage' each product has. Client coverage is defined by the percentage of clients that have a product and is between 0% and 100%. What is throwing a spanner in doing a COUNT(Products)/COUNT DISTINCT(Clients) is that some clients have some products more than once; the way I want my calculation to work is to be binary: A client has it or doesn't. I am not interested in how many times they have bought it.

 

Example data:

Client

Product

A

1

A

2

A

3

B

1

B

1

B

2

C

1

 

In this instance, all clients have product 1, but Client B has it twice. Therefore coverage should be 100% not 133% if I did the formula above.

 

Expected calculated output:

Product

Client Coverage

1

100%

2

67%

3

33%

 

Any help on this would be greatly appreciated. Thanks!

1 REPLY 1
dedelman_clng
Community Champion
Community Champion

Hi @megane123 - try something like this

 

Client Coverage =
VAR __Prod =
    COUNTX ( VALUES ( Coverage[Client] ), DISTINCTCOUNT ( Coverage[Product] ) )
VAR __Client =
    COUNTROWS ( ALL ( Coverage[Client] ) )
RETURN
    DIVIDE ( __Prod, __Client, 0 )

 

dedelman_clng_0-1627588564524.png  

dedelman_clng_1-1627588605119.png

Hope this helps

David

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.