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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
chris886
Frequent Visitor

Distinct Count and Row Count Help

Here's my sample data

 

Row NumberName

1

Chris
1Dave
1Adam
2Chris
2Evan
3Dave
3Evan
3George

 

Here are the results I'm looking for, I know that I can use Distinct Count of Row Number to get the event total for each name, but I also want the Total to show the distinct number of Names being filtered.

 

NameEvents
Chris2
Dave2
Adam1
Evan2
George1
TOTAL NAMES5
1 ACCEPTED SOLUTION
v-yilong-msft
Community Support
Community Support

Hi @chris886 ,

I create a table as you mentioned.

vyilongmsft_0-1728352905146.png

Then I create a new table and I also use the DAX code as tackytechtom mentioned.

Table 2 = SUMMARIZE ( 'Table', 'Table'[Name], "Events", COUNTROWS ( 'Table' ) )

vyilongmsft_1-1728353118242.png

Measure = 
    IF(ISFILTERED('Table'), DISTINCTCOUNT('Table'[Row Number]), DISTINCTCOUNT('Table'[Name]) )

vyilongmsft_2-1728353170867.png

Finally when you add a slicer, you will get what you want.

vyilongmsft_3-1728353233771.png

vyilongmsft_4-1728353249362.png

 

 

 

Best Regards

Yilong Zhou

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

View solution in original post

3 REPLIES 3
v-yilong-msft
Community Support
Community Support

Hi @chris886 ,

I create a table as you mentioned.

vyilongmsft_0-1728352905146.png

Then I create a new table and I also use the DAX code as tackytechtom mentioned.

Table 2 = SUMMARIZE ( 'Table', 'Table'[Name], "Events", COUNTROWS ( 'Table' ) )

vyilongmsft_1-1728353118242.png

Measure = 
    IF(ISFILTERED('Table'), DISTINCTCOUNT('Table'[Row Number]), DISTINCTCOUNT('Table'[Name]) )

vyilongmsft_2-1728353170867.png

Finally when you add a slicer, you will get what you want.

vyilongmsft_3-1728353233771.png

vyilongmsft_4-1728353249362.png

 

 

 

Best Regards

Yilong Zhou

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

tackytechtom
Super User
Super User

Hi @chris886 ,

 

How about this:tackytechtom_0-1728327391861.png

Here the measure: 

Measure = 
    IF(ISFILTERED('Table'), DISTINCTCOUNT('Table'[Row Number]), DISTINCTCOUNT('Table'[Name]) )

 

Let me know, if this helps 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Well, what you suggested did work, but only when no other filters were applied. My source table has many additional data columns. When I tried applying a filter/slicer to one of those, this table goes back to counting total rows of names (8 in sample) versus distinct names (5). 

 

So my fault for trying to simplify the issue and not provide more context. Is there a tweak to the above DAX that would account for additional filters being applied to the table or page as a whole?

 

Thanks!

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors