Slicers are not self-aware

On a recent project, I had a slicer pointing to calculation group items for common periods of time with labels like Last 7 Days, Last 30 Days, YTD, etc. The date filtering worked as expected, but I wanted to display the date range in effect so it wasn't ambiguous what was included in the Last 30 Days, for example.

The slicer header accepts a measure, so I wrote a dynamic label measure to surface the date range there, self-contained in the object. But I could never get the measure, which used a SWITCH statement based on the selected value in the slicer, to return anything at all in the slicer header. Oddly, the same measure worked as expected in a card visual. 

Broken measure in slicer header; same measure working in the KPI object below it

Checking the slicer's filter icon explained why:

Current filters do not display the selection in this slicer, itself

Other slicers' current filters do show the Period slicer

The slicer reports no filters on itself, even though I have forced it to always have one selection. Its own selection doesn't exist in its filter context. Yes, it's consistent with how the model works, but it's a surprise when you hit it.

The fix: build the measure in a separate visual and layer it on top of the slicer header.

Slicer with other visual layered on top, displaying date range
It works, although it required a second object. The filter icon on a slicer is the tell: if the slicer's selection isn't showing up there, it won't show up in a measure evaluated inside it either.

Contact Form

Name

Email *

Message *