๐Ÿง  Power BI DAX | Difference between FILTER, FILTERS, and KEEPFILTERS ๐Ÿงฉ

 Understanding the difference between FILTER, FILTERS, and KEEPFILTERS in DAX is crucial for mastering context manipulation in Power BI.


1๏ธโƒฃ FILTER Function ๐Ÿ”

Used to create a table expression that returns filtered rows from a table.

Syntax:

Dax

FILTER(table, condition)

โœ… Best for complex row-level conditions.

๐Ÿ“Œ Example:

Dax

CALCULATE(SUM(Sales[Amount]), FILTER(Sales, Sales[Region] = "East"))

2๏ธโƒฃ FILTERS Function ๐Ÿงพ

Returns the current filter context applied on a column.

Syntax:

Dax

FILTERS(column)

โœ… Used to check which filters are active.

๐Ÿ“Œ Example:

Dax

IF(ISFILTERED(Sales[Region]), VALUES(Sales[Region]), "All Regions")

3๏ธโƒฃ KEEPFILTERS Function ๐Ÿ“Œ

Preserves the existing filters when used inside CALCULATE, instead of overriding them.

Syntax:

Dax

CALCULATE([Measure], KEEPFILTERS(table[column] = value))

โœ… Ensures additive filter logic instead of replacement.

๐Ÿ“Œ Example:

Dax

CALCULATE(SUM(Sales[Amount]), KEEPFILTERS(Sales[Region] = "East"))



โš–๏ธ Quick Comparison Table


Function Purpose Context Use
FILTER Returns filtered table Row-level filtering
FILTERS Returns filter context values Context checks (e.g., slicers)
KEEPFILTERS Keeps existing filters Combine filters in CALCULATE

Comments