Formula for Gender % that returns 0%/100% when sliced by respective gender

stbrooks13

New Member
Joined
Dec 9, 2014
Messages
40
I have a formula in my dashboard that shows the % of hires by gender that is working properly until the dashboard is sliced by the respective gender. Please see formulas and results below. I need the results to show 0% and 100% respectively when the dashboard is sliced by gender.

Female = CALCULATE(COUNTA(Activity[Offer Accepted]),Activity[Offer Accepted]>0,Activity[Gender]="Female")/CALCULATE(COUNTA(Activity[Offer Accepted]),Activity[Offer Accepted]>0)
Male = CALCULATE(COUNTA(Activity[Offer Accepted]),Activity[Offer Accepted]>0,Activity[Gender]="Male")/CALCULATE(COUNTA(Activity[Offer Accepted]),Activity[Offer Accepted]>0)

Overall Results (accurate)
Female 51%, Male 48%, Not Specified 1%

Results when sliced by Female
Female 100% (accurate), Male 95% (inaccurate - should be 0%), Not Specified 1% (inaccurate - should be 0%)

Results when sliced by Male
Female 105% (inaccurate - should be 0%), Male 100% (accurate), Not Specified 1% (inaccurate - should be 0%)
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi stbrooks13

Good question!
The reason your Male/Female measures are not behaving as expected is that CALCULATE's filter arguments overwrite existing filters.
So if you are filtered on Gender=Male, then the Female measure returns (Female Count / Male Count) rather than ( 0 / Male Count)

To get the behaviour you want, you can add VALUES ( Activity[Gender] ) as a filter argument to CALCULATE, which will then be intersected with the other filter argument (either Gender=Female or Gender=Male).

Code:
Female =
CALCULATE (
    COUNTA ( Activity[Offer Accepted] ),
    Activity[Offer Accepted] > 0,
    Activity[Gender] = "Female",
    [COLOR=#ff0000][B]VALUES ( Acivity[Gender] )[/B][/COLOR]
)
    / CALCULATE ( COUNTA ( Activity[Offer Accepted] ), Activity[Offer Accepted] > 0 )

Male =
CALCULATE (
    COUNTA ( Activity[Offer Accepted] ),
    Activity[Offer Accepted] > 0,
    Activity[Gender] = "Male",
[COLOR=#ff0000][B]    VALUES ( Activity[Gender] )[/B][/COLOR]
)
    / CALCULATE ( COUNTA ( Activity[Offer Accepted] ), Activity[Offer Accepted] > 0 )

See this article for some discussion of this very issue:
SQLBI - Marco Russo : How CALCULATE works in DAX

Regards
Owen :)
 
Upvote 0

Forum statistics

Threads
1,225,730
Messages
6,186,700
Members
453,369
Latest member
positivemind

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top