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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.