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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
TSI
Advocate I
Advocate I

Table with IF function totals to zero

Hi there, 

I'm new to DAX and am probably making a mistake because I'm applying Excel logic!

 

I have employee data, which I used to create a table with headcounts and a measure of % Female:

 

Summary table.jpg

 

 

 

 

The tricky part is when I want a count of how many countries have % Female >= 30%. I added a measure:

Meets Criteria =  IF ((Female HC]/ [Total HC]) >= 0.3, 1, 0)

 

It works fine in the table, but the total is 0, when it should be 2. 

 

Could someone give me a hand here? Thank you!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @TSI 
please create below two measures. first one is for female proportion per country an second one is for count of countries where female proportion is greater than equal to 0.30. 

_femaleProportion = 
VAR _female = CALCULATE(SUM(Headcount[Female HC]),ALLEXCEPT(Headcount,Headcount[Country]))
VAR _total = CALCULATE(SUM(Headcount[Total HC]),ALLEXCEPT(Headcount,Headcount[Country]))
RETURN DIVIDE(_female,_total,0)

FinalResult = CALCULATE(DISTINCTCOUNT(Headcount[Country]),FILTER(Headcount,[_femaleProportion]>=0.30))

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @TSI 
In case of total row you are dividing 230 by 1030 which is 0.22 hence you are getting result as 0. In case you want to get sum of rows where criteria is satisfied please use

Meets Criteria = SUMX(Data,IF([% Female]>=0.3,1,0))

Hi @Anonymous 

 

Thanks for the reply. I tried the SUMX formula, but ended up with Female headcount instead.

 

Do you think it's because I am applying 'Meet Criteria' at a summarised level (i.e. it's at Country level), and not employee row level?

 

Appreciate your help!

 

Anonymous
Not applicable

Hi @TSI 
please create below two measures. first one is for female proportion per country an second one is for count of countries where female proportion is greater than equal to 0.30. 

_femaleProportion = 
VAR _female = CALCULATE(SUM(Headcount[Female HC]),ALLEXCEPT(Headcount,Headcount[Country]))
VAR _total = CALCULATE(SUM(Headcount[Total HC]),ALLEXCEPT(Headcount,Headcount[Country]))
RETURN DIVIDE(_female,_total,0)

FinalResult = CALCULATE(DISTINCTCOUNT(Headcount[Country]),FILTER(Headcount,[_femaleProportion]>=0.30))

 

Thank you @Anonymous , this worked perfectly!

Appreciate your expertise 👍

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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