58 min read

DAX KEEPFILTERS: A Practical Guide to Filter Intersections

See how DAX KEEPFILTERS intersects existing filters in Power BI. Run a small DAX fixture to compare default CALCULATE behavior with retained context.

DAX KEEPFILTERS: A Practical Guide to Filter Intersections

By jackey.ye · Updated 2026-12-01

KEEPFILTERS is a CALCULATE and CALCULATETABLE modifier that intersects a new filter with the existing filter context instead of replacing it. It only affects the columns named in its argument, leaves filters on other columns and related tables untouched, and is not supported in DirectQuery mode for calculated columns or RLS rules.

That single behavioral difference explains a whole class of reporting defects: a measure that quietly discards a slicer selection and returns a confident, wrong number. This guide covers the merge mechanism, a runnable local experiment that makes override and intersection visible side by side, the decision rule for when each behavior is correct, and a review checklist for models already in production.

What does KEEPFILTERS actually do inside CALCULATE?

It changes how CALCULATE merges a filter argument with the filter context already in effect, so that both sets of filters apply and the result is their intersection on each named column. Without it, the filter argument replaces whatever filter already sits on the same column.

Three layers make this concrete. First, the filter context is a set of filters over columns — a slicer on 'Product'[Color] puts a filter on that column, and a matrix row puts a filter on the row's column. Second, a plain CALCULATE filter argument behaves as an override: Microsoft documents that when the columns are already in the filter context, "the existing filters will be overwritten by the new filters." Third, KEEPFILTERS reverses that merge — the documentation states that "whereas CALCULATE filters replace the current context, KEEPFILTERS adds filters to the current context," and the intersection of the two sets becomes the evaluation context.

One scope point matters as much as the mechanism. Microsoft's remarks note that filters on columns other than those named in the arguments "remain in effect and unaltered." KEEPFILTERS does not widen or narrow anything it was not pointed at.

The practical consequence is a denominator problem. A ratio whose denominator uses a plain filter on 'Product'[Color] = "Red" will report the red share of all sales regardless of what the user selected, because the argument overwrote the slicer. Wrap the same predicate in KEEPFILTERS and the denominator becomes red sales within the current selection — which is usually what the business question actually asks.

How do filter intersections behave when two filters hit the same column?

The result is the set of values present in both filters. If the outer context selects {WA, OR} and the KEEPFILTERS argument selects {WA, BC}, only WA survives; if the outer context selects {OR} alone, the intersection is empty and the measure returns blank.

Same outer filter, different merge: WA+OR inner filter under a WA+BC outer filter (AdventureWorks DW) Horizontal bars comparing three documented AdventureWorks DW totals in US dollars. The first bar is the plain WA+OR total with no outer filter. The second bar is the nested CALCULATE without KEEPFILTERS, where the inner filter overrides the outer WA+BC filter and reproduces the WA+OR total. The third bar is the same nesting wrapped in KEEPFILTERS, where the intersection of WA+OR and WA+BC leaves only WA, so the total falls to the Washington-only figure. Same outer filter, different merge: WA+OR inner filter under a WA+BC outer filter (AdventureWorks DW). horizontal bar data: WA + OR, no outer filter 3.63824e+06; Nested CALCULATE, no KEEPFILTERS (override) 3.63824e+06; Nested CALCULATE with KEEPFILTERS (intersection = WA) 2.46725e+06.Source: KEEPFILTERS function (DAX) — Microsoft Learn 2024-04-25. Same outer filter, differentmerge: WA+OR inner filterunder a WA+BC outer filter(AdventureWorks DW) WA + OR, noouter filter 3.63824e+06 NestedCALCULATE, noKEEPFILTERS... 3.63824e+06 Nested CALCULATEwith KEEPFILTERS(intersection =... 2.46725e+06 Source: KEEPFILTERS function (DAX) — MicrosoftLearn (2024-04-25)

AdventureWorks DW sample-model results from Microsoft's KEEPFILTERS example. The two nested-CALCULATE rows share the same outer filter (WA or BC); only the inner filter differs. Values are sample-database output, not benchmarks for any other model.

Microsoft's KEEPFILTERS page walks through exactly this case on the AdventureWorks sample model. An inner CALCULATE filtered to WA or OR, nested inside an outer CALCULATE filtered to WA or BC, returns the Washington-and-Oregon total when the inner filter is unwrapped — the outer filter is overridden. Wrapping the inner filter in KEEPFILTERS returns the Washington-only total instead, because the intersection of the two state lists is WA. On that sample database the documented values are $3,638,239.88 for the override case and $2,467,248.34 for the KEEPFILTERS case; those figures belong to AdventureWorks DW, not to your model.

A blank is a correct answer here, not a failure. It means no row satisfies both filters simultaneously — a product cannot be Azure and Red at once. To distinguish an empty intersection from a broken measure, remove the KEEPFILTERS wrapper temporarily: if the value reappears, the intersection was empty; if it stays blank, the problem lies elsewhere, such as a broken relationship or a missing fact row. This section covers single-column filters only; multi-column tuples behave differently and are treated below.

Which situations call for KEEPFILTERS, and which call for something else?

Use KEEPFILTERS when the filter can match more than one value or spans more than one column; skip it when you deliberately want to override a single-value selection. SQLBI frames this as a rule of thumb they apply with roughly 95% confidence: one value in one column commonly means no KEEPFILTERS, while two or more values in one column, or two or more columns, commonly means KEEPFILTERS. They are explicit that exceptions exist and that the obligation is to justify the exception in a code comment, not to justify the rule.

The reasoning is about intent. A single-value filter such as 'Product'[Color] = "Red" in a denominator usually means "compare against red no matter what is selected" — that is an override, and KEEPFILTERS would blank every non-red row. A filter such as 'Product'[Color] IN { "Blue", "Red", "White" } usually means "restrict to trendy colors within the user's selection" — that is an intersection, and without KEEPFILTERS the measure can exceed 100% of the visible total. SQLBI notes that any operator other than = and == can produce a list of values, so IN, <, >, <=, >= and <> generally need the wrapper.

When the requirement is genuinely different, reach for a different tool. Plain CALCULATE filter arguments give you deliberate override. REMOVEFILTERS clears filters from a table or column, which is what a "share of grand total" denominator needs. ALLSELECTED preserves the user's outer selection as the denominator scope in a visual. Picking the wrong one produces a recognizable symptom, which the table below maps out.

Behavior

Existing filter on the same column

Typical use case

DAX pattern

Symptom when you pick the wrong one

Override

Replaced by the new filter

Fixed benchmark denominator, e.g. red-product baseline

CALCULATE ( [Sales], 'Product'[Color] = "Red" )

Slicer selections appear to do nothing; every row shows the same benchmark

Intersection

Preserved and combined with the new filter

Subset share within the user's selection

CALCULATE ( [Sales], KEEPFILTERS ( 'Product'[Color] IN { "Blue", "Red" } ) )

Blank rows where the intersection is empty; percentages that can exceed 100% when the wrapper is missing

Removal

Cleared entirely

Share of grand total, or a denominator that ignores one column

CALCULATE ( [Sales], REMOVEFILTERS ( 'Product'[Color] ) )

Totals that fail to reconcile, or a share that still moves when the slicer changes

How does KEEPFILTERS interact with relationships, RLS, and DirectQuery?

It governs only the columns named in its argument. Filters arriving from related tables, and filters on other columns of the same table, are unaffected — so cross-table behavior depends entirely on which columns the argument names, not on a general propagation rule.

Consider a model where 'Product' filters 'Sales' through a relationship. If the KEEPFILTERS argument names 'Product'[Color], the intersection applies to Color. A slicer on 'Product'[Category] continues to filter the fact table normally, because Category was never mentioned. If instead the argument names a column on the fact table, the intersection applies there and the dimension filters flow through the relationship as usual. The safe mental model is per-column, not per-table: ask which columns the argument touches, then reason about those columns alone.

For row-level security and DirectQuery, the documented limitation is specific. Microsoft states that KEEPFILTERS "is not supported for use in DirectQuery mode when used in calculated columns or row-level security (RLS) rules." That is the boundary the documentation draws. Behavior in other DirectQuery scenarios, in composite models, or in aggregations is model-specific and should be verified in your own environment rather than assumed from this article. If you maintain RLS rules in a DirectQuery model, treat any KEEPFILTERS usage there as a defect to remove, not a pattern to tune.

What is the difference between a boolean filter argument and a FILTER table expression?

Both are table-valued filters underneath, but the boolean form is the compact syntax that Import column stores are optimized for, while FILTER is reserved for conditions the boolean form cannot express. KEEPFILTERS wraps either one, and wrapping a FILTER expression changes the merge semantics in exactly the same way.

Microsoft's guidance on avoiding FILTER as a filter argument notes that the article is especially relevant for calculations that filter Import tables, and recommends passing filter arguments as boolean expressions whenever possible because Import model tables are in-memory column stores explicitly optimized to filter columns that way. The same page lists the restrictions that force a table expression: a boolean filter cannot reference columns from multiple tables, cannot reference a measure, cannot use nested CALCULATE, and cannot use functions that scan or return a table. A measure reference is the common case — filtering months where [Profit] > 0 requires FILTER over VALUES ( 'Date'[Month] ).

KEEPFILTERS is orthogonal to that choice. KEEPFILTERS ( 'Product'[Color] = "Red" ) and KEEPFILTERS ( FILTER ( ALL ( 'Product'[Color] ), 'Product'[Color] = "Red" ) ) produce the same intersection semantics; the first is simply the form the storage engine prefers. Treat boolean-versus-FILTER as a performance question and KEEPFILTERS as a semantic question, and do not let one decision drive the other.

There is one case where VALUES cannot substitute for KEEPFILTERS. SQLBI's multi-column example filters on color OR brand: KEEPFILTERS ( OR ( 'Product'[Color] = "Red", 'Product'[Brand] = "Contoso" ) ) returns blanks everywhere except the intersection of Contoso and Red, while the unwrapped version repeats the same total on every row. VALUES works on a single column only, so the two-column intersection has no VALUES equivalent — SUMMARIZE can approximate it, but KEEPFILTERS is the direct expression of intent, as shown in Using KEEPFILTERS in DAX.

How do I build a copy-ready filter-intersection experiment?

Paste one DAX query into DAX Studio or the Power BI Desktop DAX query view against a development copy of a model you control, and read the override and KEEPFILTERS columns side by side. You need a dimension table with a low-cardinality column (a product color works well) and a fact table related to it; the AdventureWorks sample model satisfies this.

The fixture

Paste this into DAX Studio or the DAX query view, then rename DimProduct, FactSales and Color to match your model. The header comment states the assumed shape, which suits a lakehouse-backed semantic model where you can validate DAX performance behavior on lakehouse models afterwards.

-- Model shape assumed by this query:
  --   DimProduct[Color]  : text column on a product-grain dimension table
  --   FactSales[SalesAmount] : numeric column on a fact table
  --   One-to-many relationship DimProduct -> FactSales (single direction)
  -- Rename tables and columns to match your model before running.
  
  DEFINE
      MEASURE FactSales[Sales Amount] =
          SUM ( FactSales[SalesAmount] )
  
      -- Override: replaces any existing filter on DimProduct[Color]
      MEASURE FactSales[Red Sales Override] =
          CALCULATE (
              [Sales Amount],
              DimProduct[Color] = "Red"
          )
  
      -- Intersection: adds to the existing filter on DimProduct[Color]
      MEASURE FactSales[Red Sales Keep] =
          CALCULATE (
              [Sales Amount],
              KEEPFILTERS ( DimProduct[Color] = "Red" )
          )
  
  EVALUATE
      CALCULATETABLE (
          ADDCOLUMNS (
              VALUES ( DimProduct[Color] ),
              "Sales Amount", [Sales Amount],
              "Red Sales Override", [Red Sales Override],
              "Red Sales Keep", [Red Sales Keep]
          ),
          DimProduct[Color] IN { "Red", "Blue" }
      )
  ORDER BY DimProduct[Color]
  

Expected output (unexecuted)

Expected output — not executed by the author. No figures are shown because the values depend entirely on your data; read the column shape, not the amounts.

DimProduct[Color]

Sales Amount

Red Sales Override

Red Sales Keep

Blue

Blue's own value

Red total (same as the Red row)

(blank)

Red

Red's own value

Red total

Red total

The override column repeats one identical value on both rows because the outer Color filter was replaced; the KEEPFILTERS column returns a value only on the row that survives the intersection. A repeated value in the KEEPFILTERS column means the filter landed on a different column than the outer context filters.

Numbered steps to run it

  1. Open DAX Studio or Power BI Desktop's DAX query view and connect to a development copy of the model, not a production dataset.

  2. Paste the fixture, confirm every table and column name resolves, and run the query.

  3. Checkpoint: Red Sales Override shows the same value on both rows; Red Sales Keep is non-blank only on the Red row.

  4. Change the outer filter to a multi-value selection, for example DimProduct[Color] IN { "Red", "Blue", "White" }, and re-run. The slicing pitfalls of multi-select are covered in DAX SELECTEDVALUE: multiple selections and blanks.

  5. Checkpoint: Red Sales Keep still returns only the Red values while Sales Amount now spans three colors. Then set the outer filter to exclude Red and re-run: Red Sales Keep goes blank on every row, which is an empty intersection, not a broken measure.

  6. If you also mirror this check as a SQL regression test, run it against a disposable local database you can drop rather than a shared instance.

How do I review an existing model for measures that silently overwrite slicer context?

Work through this checklist once per measure, and record the justification for every exception so a future maintainer can tell intent from accident.

  • Search the model's measure definitions for CALCULATE ( and list every filter argument that names a column also exposed on a slicer or visual axis.

  • Classify each one: single value in a single column, or two or more values / two or more columns. The first is a candidate override; the second is a candidate intersection.

  • For each candidate intersection, confirm whether KEEPFILTERS is present. If it is missing, check whether the measure can exceed 100% of the visible total — that is the signature of an ignored selection.

  • For each candidate override, confirm the override is deliberate. A denominator benchmark is a legitimate override; a numerator that blanks out under a slicer is usually a mistake.

  • Determine how the measure is consumed: numerator, denominator, or standalone KPI. The same filter argument can be correct in one role and wrong in another.

  • Verify blank behavior is intentional. If a blank is expected when the intersection is empty, note it; if a blank is reaching a visual as a gap, decide whether COALESCE or a different filter is warranted.

  • Look for FILTER ( used as a filter argument where a boolean expression would do, and check whether the condition genuinely needs a measure or multiple columns.

  • Confirm no KEEPFILTERS appears in DirectQuery calculated columns or RLS rules, where Microsoft documents it as unsupported.

  • Record the justification for each exception in a comment on the measure definition.

This is an inspection procedure, not a measurement study; it produces a list of decisions to defend, not a score.

What are the common misconceptions about KEEPFILTERS?

The recurring errors all trace back to one of the documented behaviors above, so each correction is short.

"KEEPFILTERS removes filters." It does the opposite. Microsoft's wording is that it adds filters to the current context and evaluates their intersection; nothing is cleared. Removal is REMOVEFILTERS' job.

"It affects every column in the model." It affects only the columns named in its argument. Filters on other columns, including columns reached through relationships, remain in effect and unaltered.

"It is a performance optimization." It is a semantic modifier. The performance guidance — prefer boolean filter arguments over FILTER — is a separate concern about how Import column stores evaluate predicates, and applying KEEPFILTERS does not by itself make a measure faster.

"A blank result means a bug." A blank often means the intersection is empty, which may be exactly the correct answer. Test by removing the wrapper before filing a defect.

"It behaves the same in DirectQuery calculated columns and RLS." It does not; Microsoft documents it as unsupported in those two contexts.

FAQ

Can KEEPFILTERS be used outside CALCULATE? Yes, in a specific sense. It is documented as a modifier for CALCULATE and CALCULATETABLE, but it also appears as an argument to iterators, where it changes how context transition merges filters over the iterated columns. SQLBI's example AVERAGEX ( KEEPFILTERS ( VALUES ( 'Date'[Month] ) ), [Sales Amount] ) shows the pattern: there is no visible CALCULATE, yet KEEPFILTERS still modifies the transition.

What happens when the intersection is empty? The measure returns blank. That is a valid result meaning no row satisfies both filters, not an error. Remove the wrapper temporarily to confirm the intersection is the cause rather than a broken relationship.

Can KEEPFILTERS and REMOVEFILTERS be combined in one CALCULATE? They can appear as separate filter arguments, and each applies to the columns it names. Keep the intent explicit: REMOVEFILTERS clears a column's filter, while KEEPFILTERS intersects one. Mixing them on the same column in one call is a sign the requirement needs restating before the formula is written.

Does KEEPFILTERS work with CALCULATETABLE? Yes. CALCULATETABLE accepts the same filter arguments as CALCULATE, and Microsoft lists KEEPFILTERS among its filter modifier functions, described as adding a filter without removing existing filters on the same columns.

How can I tell in a live report whether a measure is overriding or intersecting? Change the slicer selection and watch the measure. If the value stays fixed regardless of selection, it is overriding; if it moves with the selection and blanks out when the selection excludes the filtered value, it is intersecting. The fixture above reproduces both behaviors on demand.

Where this fits in a governed semantic layer

Filter semantics are a governance concern, not just a formula concern. A measure whose CALCULATE filter silently overrides a slicer is a definition defect that spreads through every report built on it, and the fix belongs in model review and change control rather than in a one-off patch to a single visual. Recording, per measure, whether a filter argument overrides or intersects — and why — gives reviewers and future maintainers something to check against. Platforms that treat semantic-model review as part of the analytics workflow, such as Singdata's lakehouse offering, are where that discipline has to live; the KEEPFILTERS reference documents the behavior your review is checking. For a broader look at diagnosing model-level DAX issues, see DAX performance optimization for lakehouse models and DAX SELECTEDVALUE: handling multiple selections and blanks. The next action is concrete: pick one suspect measure this week, run the fixture from this guide against it, and record whether its filter argument overrides or intersects the slicer.

Related Articles