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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
PRFInstitute
New Member

Power BI - Distinct Count not working

Hi, I've a Pie chart on my dashboard in Power BI. The Pie chart is based on the column that inlcudes duplicates. I have a card on my dashboard that shows me the number of distinct values in that column & also the total number values (no. of rows in excel). When I select "Count" the pie chart works well but when I select "Distinct Count", I expect the Pie chart to change values on only have the unique distinct in it. However, when totalling the numbers of the slices.

Power BI.PNG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @PRFInstitute ,

 

When you place in the card visual object, the distinguish count counts the number of all non-repeating values in the u-id column only (i.e. un1-un6,un8-9, 8 in total), and when you add a classification of age to the pie chart, the distinguish count counts the number of all non-repeating values in the u-id column according to different ages. But different ages may have the same u-id, so the sum of the numbers shown in the pie chart does not match the card, due to the design of the power bi desktop.

vtangjiemsft_0-1687327527189.pngvtangjiemsft_1-1687327660630.pngWhen the age is [45-54], the unduplicated value of u-id is 1.

vtangjiemsft_2-1687327675896.png

vtangjiemsft_3-1687327773978.pngvtangjiemsft_4-1687327824846.png

If you want to display the calculated sum of the unduplicated values of u-ids of different ages (in the example 3+6+1=10) on the card visual object, you can create a measure to be placed on the card visual object.

count of u-id by age range = sumx(VALUES('Unified 2 16 23 v 16b'[D1. Age Range]),'Unified 2 16 23 v 16b'[DistinctCountMeasure])

vtangjiemsft_0-1687328471058.png

 

 

Best Regards,

Neeko Tang

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
Anonymous
Not applicable

Hi @PRFInstitute ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_0-1687140028037.png

(2) We can create a measure. 

DistinctCountMeasure = CALCULATE(DISTINCTCOUNT(Table[Column]), ALLEXCEPT(Table, Table[Category]))

Replace with the name of your table, with the column you want to count distinct values, and with the column you want to group by. After creating the measure, use it in your Pie chart instead of the original column.

DistinctCountMeasure = CALCULATE(DISTINCTCOUNT('Table'[u-id]), ALLEXCEPT('Table', 'Table'[age]))

(3) Then the result is as follows.

vtangjiemsft_1-1687140211538.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

Thank you so much for your response, however this didn't solve my issue. Since I don't have the permission to upload the pbix here, I've uploaded the pbix file to WeTransfer and here is the link for it. This pbix includes a pie chart for Age Range. I'm facing the same issue. It calculates the distinct IDs properly on the card but the same doesn't translate to Power BI.

https://we.tl/t-E7lM0kSyJP

 

It can be becuase of the other columns I have but I'm not sure about it.

 

TIA.

Anonymous
Not applicable

Hi @PRFInstitute ,

 

When you place in the card visual object, the distinguish count counts the number of all non-repeating values in the u-id column only (i.e. un1-un6,un8-9, 8 in total), and when you add a classification of age to the pie chart, the distinguish count counts the number of all non-repeating values in the u-id column according to different ages. But different ages may have the same u-id, so the sum of the numbers shown in the pie chart does not match the card, due to the design of the power bi desktop.

vtangjiemsft_0-1687327527189.pngvtangjiemsft_1-1687327660630.pngWhen the age is [45-54], the unduplicated value of u-id is 1.

vtangjiemsft_2-1687327675896.png

vtangjiemsft_3-1687327773978.pngvtangjiemsft_4-1687327824846.png

If you want to display the calculated sum of the unduplicated values of u-ids of different ages (in the example 3+6+1=10) on the card visual object, you can create a measure to be placed on the card visual object.

count of u-id by age range = sumx(VALUES('Unified 2 16 23 v 16b'[D1. Age Range]),'Unified 2 16 23 v 16b'[DistinctCountMeasure])

vtangjiemsft_0-1687328471058.png

 

 

Best Regards,

Neeko Tang

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

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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