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

Count Distinct Name where a sum condition is met

Hello I have yet to find a distinct count of "Project Name" where the sum of the "Actual Hrs." and "Planned Hrs" are > 0.

It has to be distinct count and sum because some projects have instances where there is 0 Actual Hrs. 

 

I am trying to make this work:

  CALCULATE(DISTINCTCOUNT('Project Hours'[Project Name]),Sum('Project Hours'[Actual Hrs.])>0,Sum('Project Hours'[Planned Hrs.])<.01)

 

,but Dax does not allow sum within calculate function (I also tried SUMX and it also is not allowed)

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @Anonymous 

COUNTROWS (
    FILTER (
        DISTINCT ( 'Project Hours'[Project Name] ),
        CALCULATE ( SUM ( 'Project Hours'[Actual Hrs.] ) > 0 )
            && CALCULATE ( SUM ( 'Project Hours'[Planned Hrs.] ) < .01 )
    )
)

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

View solution in original post

3 REPLIES 3
AlB
Community Champion
Community Champion

@Anonymous 

Keeping the approach you were trying, you could do stg like:

 

CALCULATE (
    DISTINCTCOUNT ( 'Project Hours'[Project Name] ),
    FILTER (
        DISTINCT ( 'Project Hours'[Project Name] ),
        CALCULATE ( SUM ( 'Project Hours'[Actual Hrs.] ) > 0 )
            && CALCULATE ( SUM ( 'Project Hours'[Planned Hrs.] ) < .01 )
    )
)

 

but it'd be a bit redundant

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

AlB
Community Champion
Community Champion

Hi @Anonymous 

COUNTROWS (
    FILTER (
        DISTINCT ( 'Project Hours'[Project Name] ),
        CALCULATE ( SUM ( 'Project Hours'[Actual Hrs.] ) > 0 )
            && CALCULATE ( SUM ( 'Project Hours'[Planned Hrs.] ) < .01 )
    )
)

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Anonymous
Not applicable

You're amazing!!!! Thank you so much!!!! 

 

Ok, now I understand. You have to do calculate for sum and condition and then in outter layer do a filter for the calculate (filter on distinct count of "Name"). Also each sum condition has to be in its own calculate function 

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.