Forum Discussion
Table with IF function totals to zero
- Anonymous6 years ago
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))
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
- TSI6 years ago
Advocate I
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!
- Anonymous6 years agoNot 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))- TSI6 years ago
Advocate I
Thank you Anonymous , this worked perfectly!
Appreciate your expertise 👍