Power BI: CALCULATE is ignoring my slicer — why?

posée 5 months ago281 vuesen

7

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.

posée 5 months ago

1 réponse

4
✓
✓ Réponse acceptée

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é.

answered 5 months ago

Sign in and verify your email to post an answer.