AlexanderKornMS's avatar
AlexanderKornMS
Microsoft Employee
3 months ago

Fix Slicers with Custom Visual SLICERBAR

Fabric-Notebooks/Migrate Slicers to SLICERBAR.ipynb at main · KornAlexander/Fabric-Notebooks

Migrate Native Slicers → SLICERBAR

This notebook consolidates the native Power BI slicer visuals on a report page into a single SLICERBAR custom visual using the fix_migrate_slicer_to_slicerbar fixer from the PBI Fixer build of semantic-link-labs

Purpose

Reports often accumulate many individual slicer visuals that clutter the canvas and consume real estate. The SLICERBAR custom visual collapses all of those filters into one compact, modern control. This fixer automates that migration directly against the report definition (PBIR) — no manual rebuilding required.

What it does

For the page you specify, the fixer:

  1. Finds the SLICERBAR visual on the page. If none exists, it creates a narrow one in the top-right corner and registers the custom visual in the report.
  2. Finds every native slicer visual on the page.
  3. For each slicer, extracts its field (Entity + Property) and adds it to the Slicer Bar's query + configuration.
  4. Skips duplicates (a field already present in the Slicer Bar) but still removes the redundant native slicer.
  5. Deletes the original native slicers once migrated.

Requirements

  • The report must be in PBIR format. If it is in the legacy format, run Upgrade to PBIR first.
  • Use scan_only=True for a safe dry run before committing changes.
 
 

1. Install

Install the PBI Fixer build of semantic-link-labs. The PySpark kernel restarts automatically after install — that is expected. Run this once per session.

 
 

2. Import the fixer

 
from sempy_labs.report._Fix_MigrateSlicerToSlicerbar import fix_migrate_slicer_to_slicerbar
 
 

3. Dry run (recommended first)

scan_only=True reports exactly which slicers would be migrated — nothing is written to the report. Review the output before running the real migration.

 
fix_migrate_slicer_to_slicerbar(report="report name", page_name="page name", scan_only=True)
 
 

4. Run the migration

This applies the changes: it creates the Slicer Bar if missing, migrates the native slicers into it, and deletes the originals.

 
fix_migrate_slicer_to_slicerbar(report="report name", page_name="page name")
 
 

Parameters

Parameter Description
reportName or ID of the report.
page_nameDisplay name of the page to migrate.
workspaceWorkspace name or ID. Defaults to the attached lakehouse / notebook workspace.
scan_onlyIf True, only reports what would change without writing.

Notes

  • When no Slicer Bar exists on the page, a new one is placed top-right, 200 px wide, full page height, titled Slicers.
  • The SLICERBAR custom visual is registered in report.json automatically (idempotent).
  • Re-running on a page that already has all fields migrated simply removes any leftover duplicate native slicers.

 

 

 

No RepliesBe the first to reply