KEEPFILTERS DAX Function (Filter)

Changes the CALCULATE and CALCULATETABLE function filtering semantics.


KEEPFILTERS ( <Expression> )
Parameter Attributes Description

CALCULATE or CALCULATETABLE function expression or filter.

Return values

Even though KEEPFILTERS could be considered a table function, as a filter modifier it changes the behavior of a predicate or of the table expression provided as an argument. Therefore, it cannot be considered a function returning a value.


KEEPFILTERS is a filter modifier that does not remove an existing column or table filter in the filter context that conflicts with the filter applied by the argument of KEEPFILTERS used as:

  • a filter argument in CALCULATE / CALCULATETABLE
  • an argument of an iterator used in a following context transition


In the following example, KEEPFILTERS is used as a filter modifier in CALCULATE. The Always Red Sales measure returns always the sum of the Red products, overriding any existing filter over the Color column. The measure Only Red Sales return the sales of red products within the set of selected colors. If Red is not included in the current filter context, the result is blank.

Always Red Sales :=
    [Sales Amount],
    'Product'[Color] = "Red"

Only Red Sales :=
    [Sales Amount],
    KEEPFILTERS ( 'Product'[Color] = "Red" )

When KEEPFILTERS is used for an iterator, it keeps the existing filter context when there is a context transition. The measure Average Sales Only Trendy Colors computes the average Sales of the colors included within the Trendy Colors, without considering those that are not in the current filter context. If the measure is evaluated in a filter context that has a filter over Red, Yellow, and White, the result will average only Red and White, ignoring Yellow and Blue colors.

Average Sales Only Trendy Colors :=
VAR TrendyColors =
        { "Red", "Blue", "White" },
        KEEPFILTERS ( TrendyColors ),
        [Sales Amount]

Related articles

Learn more about KEEPFILTERS in the following articles:

Related functions

Other related functions are:

Last update: Sep 27, 2020   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo

MSDN documentation:

Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.


Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.


This function is deprecated. Jump to the Alternatives section to see the function to use.


This parameter is deprecated and its use is not recommended.


Want to improve the content of KEEPFILTERS? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.