DAX function
KEEPFILTERS — DAX function reference
Add a filter without overriding.
Syntax
dax
CALCULATE(<expression>, KEEPFILTERS(<filter>))
Examples
dax
CALCULATE([Sales], KEEPFILTERS(Sales[Region] = "West"))
→ A number
Without KEEPFILTERS, every row of a category-sliced visual would show the Bikes total because the boolean filter overrides the existing context.
dax
CALCULATE(SUM(Sales[Amount]), KEEPFILTERS(Product[Category] = "Bikes"))
→ Only returns a value for Bikes; other categories return blank
dax
CALCULATE(SUM(Sales[Amount]), KEEPFILTERS(Sales[Amount] > 500))
→ Combines with any existing amount filter instead of overriding it
Common mistakes & gotchas
- Intersects with existing context instead of replacing it.
- Normally a CALCULATE filter argument overrides existing context on the same column; KEEPFILTERS intersects (ANDs) with it instead — the visible symptom of forgetting it is a matrix where every row shows an identical total.
- KEEPFILTERS has no effect when there's no pre-existing filter on that column to intersect with — it doesn't change results unless the filter it wraps overlaps existing context.
Related DAX functions
From Filter context