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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Moyfeartu23
Frequent Visitor

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 @Moyfeartu23 ,
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 @Moyfeartu23 ,
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

 



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])
)
)

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
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.