Power BI: CALCULATE is ignoring my slicer — why?
posée 5 months ago281 vuesen
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.
Diagnostic IA
Généré par IA. Ce n'est pas une réponse — la communauté ci-dessous le confirme ou le corrige. Vérifiez toujours avant de vous y fier.
1 réponse
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).
Connectez-vous pour dire si ça a marché.
Sign in and verify your email to post an answer.