๐Ÿง  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