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

Calculate distinct count based on 2 columns

Hi 

 

I'm trying to get the distinct count of every project assigned to each unit. For the days that there's only one unit I'm getting the calculation right but not for those days with 2 or more units.

 

With this formula I'm getting the following result:

 

count project =
SUMX(VALUES('HS per Project'[Ship Date (bins)]), CALCULATE(DISTINCTCOUNT('HS per Project'[Project]), ALLSELECTED('HS per Project')))

 

Capture.JPG 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,
Thanks to @shravanreddy133  for the great ideas.
This dax can be modified as

Count Project = 
SUMX(
    VALUES('HS per Project'[Ship Date]), 
    CALCULATE(
        DISTINCTCOUNT('HS per Project'[Project]), 
        ALLEXCEPT('HS per Project', 'HS per Project'[Ship Date], 'HS per Project'[Unit])
    )
)

Fianl output

vheqmsft_0-1709531095608.png

 



View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,
Thanks to @shravanreddy133  for the great ideas.
This dax can be modified as

Count Project = 
SUMX(
    VALUES('HS per Project'[Ship Date]), 
    CALCULATE(
        DISTINCTCOUNT('HS per Project'[Project]), 
        ALLEXCEPT('HS per Project', 'HS per Project'[Ship Date], 'HS per Project'[Unit])
    )
)

Fianl output

vheqmsft_0-1709531095608.png

 



Anonymous
Not applicable

Thanks for the help @Anonymous. This one solved my problem!

Try Using ALLEXCEPT instead of ALL SELECTED: 

SUMX(
VALUES('HS per Project'[Ship Date (bins)]),
CALCULATE(
DISTINCTCOUNT('HS per Project'[Project]),
ALLEXCEPT('HS per Project', 'HS per Project'[Unit])
)
)

Anonymous
Not applicable

Hi @shravanreddy133  it did fix the units that does not repeat over the days but everything else is wrong. Seems that now it's counting the projects of the same unit without considering they are from different dates.

 

 

 

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.