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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
DA1981
Frequent Visitor

Coverage calculation

Hello everbody,

 

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:

ClientProduct
A1
A2
A3
B1
B1
B2
C1

 

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 caluculated output:

 

ProductClient Coverage
1100%
267%
333%

 

Any help much appreciated. Thanks in advance.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

This is something similar to what I've posted before:

 

[Client Coverage] =
var TotalClientCount =
	CALCULATE(
		DISTINCTCOUNT( T[Client] ),
		// Using allselected here means
		// that the results will be relative
		// to the currently visible/selected
		// set of clients. If you want to
		// get the ratios in absulute terms,
		// change this to ALL( T ).
		ALLSELECTED( T )
	)
var Result =
	AVERAGEX(
		DISTINCT( T[Product] ),
		CALCULATE( DISTINCTCOUNT( T[Client] ) )
			/ TotalClientCount
	)
return
	Result

By the way, this solution comes with a huuuuuge warning: You should never use single-table models in production. If you want to know one of the many reasons why not, please check this out: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Why-one-table-models-will-produce-WRONG-NUMBE...

 

 

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

I remember having solved this problem on this forum. Where's the solution???

Hi. Thanks for the response. This was posted twice in error so you replied to the other post.

 

And you didnt solve it, which is why I never accepted a solution. You declared 2 variables and only used one of them, which made no sense.

Anonymous
Not applicable

This is something similar to what I've posted before:

 

[Client Coverage] =
var TotalClientCount =
	CALCULATE(
		DISTINCTCOUNT( T[Client] ),
		// Using allselected here means
		// that the results will be relative
		// to the currently visible/selected
		// set of clients. If you want to
		// get the ratios in absulute terms,
		// change this to ALL( T ).
		ALLSELECTED( T )
	)
var Result =
	AVERAGEX(
		DISTINCT( T[Product] ),
		CALCULATE( DISTINCTCOUNT( T[Client] ) )
			/ TotalClientCount
	)
return
	Result

By the way, this solution comes with a huuuuuge warning: You should never use single-table models in production. If you want to know one of the many reasons why not, please check this out: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Why-one-table-models-will-produce-WRONG-NUMBE...

 

 

 

Anonymous
Not applicable

@DA1981 

 

I did solve it. I even created a quick solution in PBI to convince myself that it did return what you expected. Can you please find the link to the other post and place it here? Or if not, do you have the solution I gave you somewhere?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors