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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

How do I make DAX measures respect cross-filtering from other visuals?

Hi all,

I need help to write a DAX measure that will respond to cross-filtering. I'm developing a report for a hospital on their homeless patient population, and I'm trying to show the percent of appointments that were completed, canceled, and no-showed based on an [Appt Status] column. I have three different sets of measures, one for each possible status. Everything works fine until that column is cross-filtered. The measures for "Canceled" status are below:

Selected Appointments = COUNTROWS( 'Appointments' )
Canceled Appointments = CALCULATE(
    [Selected Appointments],
    Appointments[Appt Status] = "Canceled [3]"
)
% Canceled = IF(
    [Selected Appointments] = 0,    --If there are no appts in the denominator, 
    BLANK(), --then display blank.
    DIVIDE( [Canceled Appointments], [Selected Appointments] ) + 0 --If there were some appts, but none were canceled, show 0.0%.
)

The underlying data looks something like this: 

Underlying data screenshot.png

In the table below, I summarize the % of appointments completed and canceled by department category. The bar chart shows the total number of appointments by status. Not cross-filtered screenshot.pngWhen I click on the bar chart and cross-filter by "Canceled" status, the "Appts" column in the table is filtered, but "Completed Appts" and "Canceled Appts" (which come from my DAX measures) do not change. As a result, "% Completed" has a non-sensical result. How do I rewrite my measures so that they will respect the cross-filtering and evaluate to zero if a particular appointment status is not in the cross-filtered filter context?

Cross-filtered screenshot.png

Thanks in advance for your help!

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

Try adding a KEEPFILTERS to the CALCULATE:

Canceled Appointments = CALCULATE(
    [Selected Appointments],
    KEEPFILTERS(Appointments[Appt Status] = "Canceled [3]")
)

This will respect other filters that are also flowing into the measure.

View solution in original post

3 REPLIES 3
OwenAuger
Super User
Super User

Hi @Anonymous 

 

I recommend wrapping the Filter argument of CALCULATE in KEEPFILTERS.

Normally, the Filter arguments of CALCULATE overwrite existing filters, but using KEEPFILTERS modifies this behaviour so that they are intersected with existing filters.

 

For example, your Canceled Appointments measure would be:

Canceled Appointments =
CALCULATE(
    [Selected Appointments],
    KEEPFILTERS ( Appointments[Appt Status] = "Canceled [3]" )
)

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn
Anonymous
Not applicable

Thank you very much, @OwenAuger  and @jdbuchanan71! KEEPFILTERS solved the problem! 

jdbuchanan71
Super User
Super User

Try adding a KEEPFILTERS to the CALCULATE:

Canceled Appointments = CALCULATE(
    [Selected Appointments],
    KEEPFILTERS(Appointments[Appt Status] = "Canceled [3]")
)

This will respect other filters that are also flowing into the measure.

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.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors