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
DHB
Helper V
Helper V

Use Filters in Measure DAX

I have a list a set of data which I've used this DAX to calculate percentages of the total records;

 

DIVIDE(COUNT(ACTIVITY[PERSON_CODE]),CALCULATE(COUNT(ACTIVITY[PERSON_CODE]),ALL(ACTIVITY)))

 

In one of my report pages the data is filtered to one particular year and 'active' users only so I'd like to create a new measure which takes this into account so that all 'active' users in 2019=100%.  At the moment it's giving me 60% because it's taking into account 2020 and other user states.  This is my first attempt at the new DAX but it doesn't work;

 

DIVIDE(FILTER(ACTIVITY,[YEAR]=2019&(ACTIVITY[ENROL_WF]="active"))[COUNT(ACTIVITY[PERSON_CODE]),CALCULATE(COUNT(ACTIVITY[PERSON_CODE]),ALL(ACTIVITY)))
 
Can anyone give me any advice on how to fix it up?
 
Thanks,
 
DHB
2 ACCEPTED SOLUTIONS
mahoneypat
Microsoft Employee
Microsoft Employee

I would first try your original measure with ALLSELECTED() instead of ALL().

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

Anonymous
Not applicable

Hi @DHB ,

 

You may try to use the below measure:

DIVIDE(COUNT(ACTIVITY[PERSON_CODE]),CALCULATE(COUNT(ACTIVITY[PERSON_CODE]),ALLSELECTED(ACTIVITY)))

 Please try.

Aiolos Zhao

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi @DHB ,

 

You may try to use the below measure:

DIVIDE(COUNT(ACTIVITY[PERSON_CODE]),CALCULATE(COUNT(ACTIVITY[PERSON_CODE]),ALLSELECTED(ACTIVITY)))

 Please try.

Aiolos Zhao

mahoneypat
Microsoft Employee
Microsoft Employee

I would first try your original measure with ALLSELECTED() instead of ALL().

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thanks Pat, that works but I have another issue now.  I'm representing that measure in a gauge visual and when I apply filters in the report the value stays at 100%.  With the DAX I used before it only showed 60% but when I used filters this would go up and down between 0-60.  Can I use the ALLSELECTED version and still have the gauge correspond to the filters I use somehow?

@DHB , try like

DIVIDE(calculate([COUNT(ACTIVITY[PERSON_CODE]),FILTER(ACTIVITY,ACTIVITY[YEAR]=2019&(ACTIVITY[ENROL_WF]="active"))),CALCULATE(COUNT(ACTIVITY[PERSON_CODE]),ALL(ACTIVITY)))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @DHB ,

 

You need to tell us what's your expected result finally. Because the allselected function is to calculate % by person code.

 

Please show us the sample data(what you want) and show us what you want(screenshot or image).

It's better to give some examples for different scenarios.

 

Aiolos Zhao

This page in my report is filtered to 2019 and active users (1102 in total).  My original DAX didn't filter out other years or user states so gave me a % of 60.9 in the gauge.  the new DAX gives me the right % but it doesn't change when I move the slider on the left.

 

Sorry - picture wouldn't upload

Capture.PNG

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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!

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.

Top Solution Authors
Top Kudoed Authors