When working with DAX in Power BI, one of the most subtle yet powerful functions you’ll encounter is KEEPFILTERS. At first glance, it may seem unnecessary; after all, you already have a filter context. But when used properly, KEEPFILTERS can give you greater control over filter propagation and help you to avoid overwriting filters in ways you didn’t intend.

What is KEEPFILTERS?

By default, when you apply a filter inside a measure with CALCULATE, it replaces the existing filter on that column.

That’s why KEEPFILTERS is often called a filter preservation function.

Basic Example

Imagine you have a Sales table with columns.

Scenario 1. Without KEEPFILTERS

If you place the measure below on a visual, such as a table, and slice by year, the slicer will be ignored because the filter Year = 2016 overrides any other Year filter.

Sales_2016 = 
CALCULATE (
    [total_sales],
    Sales[Year] = 2016
)

Without KEEPFILTERS

Scenario 2. With KEEPFILTERS

Now, if you slice by Year, only the intersection is considered, as seen in the screenshot below.w

This preserves slicer interactivity and avoids unintended overwriting.

Sales_2016_Keep =
CALCULATE (
    [total_sales],
    KEEPFILTERS (
        Sales[Year] = 2016
    )
)

Slicer Interactivity

Practical Use Cases for KEEPFILTERS

1. When You Want Narrowed Filters

Suppose you want to calculate Sales in the Accessories subcategory, but only for whatever Region the user selects.

Accessories Sales =
CALCULATE (
    [total_sales],
    KEEPFILTERS (
        Sales[SubCategory] = "Accessories"
    )
)

Narrowed Filters

2. When Working with IN or Multiple Conditions

If a report user selects only "Canada", the result is just Canada. If they select "Mexico" from the slicer, the measure returns blank because the two conditions don’t overlap.

Sales_US_CA =
CALCULATE (
    [total_sales],
    KEEPFILTERS (
        Sales[Country] IN { "United States", "Canada" }
    )
)

Multiple Conditions

Best Practices for Using KEEPFILTERS