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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Total Count of records based on Measure Value

Hello Experts,

 

I am looking for help for calculating the Total Count of Distinct Customer Names in Customer Dimension based on a Measure (M Value) in DimCustomer and at the same time the count should be dynamic to change with filter selection. Something like

AmitGarg_0-1618391908212.png

 

 

My Data Model is like

AmitGarg_1-1618391908220.png

 

Here

M Value = SUMX(RELATEDTABLE(FactSales),FactSales[Revenue] )

 

Customer Count = COUNTROWS(ALL(DimCustomer[CustomerName]))

 

I know I did COUNTROWS on ALL and no filter will be applied. So what I am looking for is

CustomerCount where

 

  1. M Value is not BLANK()
  2. Distinct Customer Name
  3. Can be filtered based on Country or any other column
1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Please refer to the following measure:

 

Customer Count = CALCULATE(Distinctcount(DimCustomer[CustomerName]),FILTER(ALLSELECTED(DimCustomer),[M Value]<> Blank())

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

 

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Try

Customer Count = Distinctcount(DimCustomer[CustomerName])

 

or

 

Customer Count = calculate(Distinctcount(DimCustomer[CustomerName]),all(DimCustomer))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

Hi @amitchandak 

 

Distinct Count wont work as it will give me the count = 1 at each customer level where as i want total count

 

and Customer Count = calculate(Distinctcount(DimCustomer[CustomerName]),all(DimCustomer)) is same as 

Customer Count = COUNTROWS(ALL(DimCustomer[CustomerName]))
 
which gives me total distinct count at each row but my requirement 1 and 3 is still not covered. 

 

 

Hi @Anonymous ,

 

Please refer to the following measure:

 

Customer Count = CALCULATE(Distinctcount(DimCustomer[CustomerName]),FILTER(ALLSELECTED(DimCustomer),[M Value]<> Blank())

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

 

Anonymous
Not applicable

Thanks Dedmon, 

 

The solution is acceptable. I was close enough but could not strike ALLSELECTED

 

Customer Count = CALCULATE(Distinctcount(DimCustomer[CustomerName]),FILTER(DimCustomer,[M Value]<> Blank())

 

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!

December 2024

A Year in Review - December 2024

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