Power BI: CALCULATE is ignoring my slicer — why?
poze 5 months ago277 gadeen
My measure:
Sales Bikes = CALCULATE([Total Sales], Product[Category] = "Bikes")
When the user picks "Accessories" in a Category slicer, this measure still shows bike sales. I expected it to be blank.
Dyagnostik IA
Se IA ki fè l. Se pa yon repons — kominote a anba a konfime oswa korije l. Toujou verifye anvan ou fye l.
1 Repons
That's by design. A boolean filter argument in CALCULATE replaces any existing filter on that column. It's shorthand for FILTER(ALL(Product[Category]), ...), so the slicer selection on Category is overwritten.
To intersect with the current selection instead, wrap it in KEEPFILTERS:
Sales Bikes =
CALCULATE([Total Sales], KEEPFILTERS(Product[Category] = "Bikes"))
Now if the slicer selects Accessories, the intersection is empty and the measure returns blank.
Rule of thumb: use KEEPFILTERS when the measure should *respect* user selections, and the plain form when it should *override* them (e.g. "% of Bikes" comparisons).
Konekte pou di lòt moun si li te mache.
Sign in and verify your email to post an answer.