set_slicer_selection
Apply a targeted offline fix to a .pbix slicer, setting it to single-select and optionally pre-selecting a default, so field-parameter charts render.
Instructions
TARGETED offline slicer fix: open a CLOSED .pbix, make a slicer SINGLE-SELECT (and optionally pre-select a default value), then write the .pbix back (DataModel preserved). Single-select writes the ground-truth objects.selection[0].properties.strictSingleSelect = true - Power BI's 'Single select', which forces exactly one item AND auto-picks the first available option when none is selected. THIS is the fix for a field-parameter axis that flat-lines: a field-parameter-bound chart only renders when its slicer is filtered to ONE option. Locate the slicer by its title (e.g. 'Chart Period'), config name, or its bound field (e.g. 'Brand Chart Axis'). default_value (optional) is written as a Categorical selection filter in the slicer's container so it opens on that specific value. The .pbix must NOT be open in Power BI Desktop.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | Yes | page name or displayName | |
| pbix | Yes | absolute path to the .pbix (must be CLOSED in Power BI Desktop) | |
| slicer | Yes | the slicer: its title (e.g. 'Chart Period'), config name, or bound field (e.g. 'Brand Chart Axis') | |
| default_value | No | optional default value to pre-select (e.g. 'MonthYear') | |
| single_select | No | true = single-select (writes strictSingleSelect: forces one item, auto-picks the first if none) |