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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Mansfig2
New Member

Count Distinct with condition across partition

Hey guys,

 

I'm struggling to find a DAX based solution to this problem I'm having, this is the table I have:

 

Mansfig2_2-1647944593502.png

 

How would I count the number of distinct values within column 2, grouping within the ID in the first column?

 

The count should look something like this: 

Mansfig2_1-1647944579060.png


Thanks for the help! 

 

George

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Mansfig2 ,

You can create a calculated column as below:

CountDistinct = 
CALCULATE (
    DISTINCTCOUNT ( 'Table'[ID2] ),
    FILTER ( 'Table', 'Table'[ID1] = EARLIER ( 'Table'[ID1] ) )
)

yingyinr_0-1648183561718.png

Best Regards

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Mansfig2 ,

You can create a calculated column as below:

CountDistinct = 
CALCULATE (
    DISTINCTCOUNT ( 'Table'[ID2] ),
    FILTER ( 'Table', 'Table'[ID1] = EARLIER ( 'Table'[ID1] ) )
)

yingyinr_0-1648183561718.png

Best Regards

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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