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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
silverbullet1
Regular Visitor

Count of Distinct Values not working

Hi there,

I have the following dataset...

current.JPG

Sample APR is a calculated column which contains randomly generated numbers.

APR Group groups these. So basically 5.X = 5, 6.X = 6, etc etc.

I want to create a third calculated columns which counts the number of distinct values in the Sample APR column, desired output like the following....

desired.JPG

I naturally tried to use DISTINCTCOUNT, with the following DAX:

Num of Cases = DISTINCTCOUNT('myTable'[Sample APR])
 
However, when I use this, I get the enture column populated by the value of 11341 which will be the number of rows of data I have I suspect. I also tried DISTINCTCOUNT with APR Group column to see what the result was and this resulted in the entire columns being populated with the a value of 12 (incidently I noticed this number is the COUNT of the number of case statements I used to create the APR Group column).
Can anyone help me out with this please?
3 REPLIES 3
tex628
Community Champion
Community Champion

Test = CALCULATE(DISTINCTCOUNT(Table1[Sample APR]),ALL(Table1), Table1[APR Group] = EARLIER(Table1[APR Group]))

Connect on LinkedIn

Thanks @tex628 

That appears to be grouping the APR Group column rather than the Sample APR one though. Been trying variations of your solution but still no luck unfortunately.

My apologies, i didnt read the initial post well enough!

Column = CALCULATE(COUNTROWS(Table1) , ALL(Table1) , Table1[Sample APR] = EARLIER(Table1[Sample APR]) , Table1[APR Group] = EARLIER(Table1[APR Group]))


Hope it works!


Connect on LinkedIn

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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