Power BI: Switch Charts by Slicer Selection (MDG)
Learn how to switch a Power BI bar chart when the MDG slicer is selected — DAX flag, visual-level filters, bookmarks and mask card techniques explained.
How can I configure a Power BI visualization to change based on slicer selection? I have a slicer with 9 domains (e.g., finance, sell, etc.) and display the same bar chart for 8 of them. When the 9th domain (MDG) is selected, I want to hide the original bar chart and show a different bar chart sourced from a different table. What is the best approach to implement this conditional visualization behavior in Power BI?
To dynamically switch Power BI visualizations when a specific slicer value (MDG) is selected, the most efficient approach uses DAX measures to detect the slicer selection and control which chart data is displayed. By creating a flag measure that identifies the MDG selection and then applying conditional logic to return either the original data (for non-MDG domains) or alternative data (for MDG), you can seamlessly change the visualization content without complex UI manipulations.
Contents
- Overview of Conditional Visualization in Power BI
- Approach 1: DAX Flag and Conditional Measures
- Approach 2: Bookmarks and Buttons
- Approach 3: Field Parameters / Disconnected Slicer
- Implementation Checklist
- Limitations and Pro Tips
Overview of Conditional Visualization in Power BI
Power BI slicers inherently filter visuals on the same page by default, but they don’t natively support swapping entire visualizations based on selections. Microsoft’s official documentation confirms that slicers update all visuals unless you modify visual interactions. To achieve domain-specific chart switching—like showing a different bar chart for the MDG domain—you need to implement conditional logic. This typically involves DAX measures to detect slicer states and control data visibility or use UI navigation techniques like bookmarks. The key is ensuring the solution remains maintainable for users with limited DAX experience while handling the 9-domain requirement efficiently.
Approach 1: DAX Flag and Conditional Measures
This method uses DAX to detect the MDG selection and conditionally return data for either the original or alternate chart. It’s the most direct approach for your use case.
Step 1: Create a Detection Measure
Add this DAX measure to your model to identify when MDG is selected:
IsMDGSelected =
IF(
SELECTEDVALUE(Domain[Domain]) = "MDG",
TRUE(),
FALSE()
)
Note: Use ISFILTERED(Domain[Domain]) instead of SELECTEDVALUE() if the slicer allows multi-select and you only want to detect MDG when it’s the only selection.
Step 2: Build Conditional Measures
Create two measures—one for your standard bar chart and one for the MDG-specific chart:
StandardChart_Value =
IF(
NOT [IsMDGSelected],
SUM(StandardTable[Value]),
BLANK()
)
MDGChart_Value =
IF(
[IsMDGSelected],
SUM(MDGTable[Value]),
BLANK()
)
Step 3: Apply to Visuals and Filtering
- Use
[StandardChart_Value]in your original bar chart (replace the existing value field). - Use
[MDGChart_Value]in your alternate bar chart (positioned identically). - Add
[IsMDGSelected]to both visuals’ Filters pane as a visual-level filter:- For the standard chart: Set “Show items when value is” =
FALSE - For the MDG chart: Set “Show items when value is” =
TRUE
- For the standard chart: Set “Show items when value is” =
Step 4: Handle Visual Masking (If Needed)
For visuals that don’t fully hide (e.g., maps, waterfalls), add a Card visual with conditional formatting:
Card_Background =
IF(
[IsMDGSelected],
"#FFFFFF", // White background (hides MDG chart)
"#FFFFFF" // Transparent background (shows standard chart)
)
Set the card’s background to this hex value and layer it over the inactive visual. ExceibratorBI’s tutorial provides detailed masking steps.
Approach 2: Bookmarks and Buttons
This technique uses Power BI’s bookmark feature to toggle between visual states, ideal for complex report designs.
Implementation Steps:
- Create two identical page layouts—one with the standard chart, one with the MDG chart.
- Select each layout, go to View > Bookmarks, and create bookmarks (e.g., “StandardView”, “MDGView”).
- Add a button for each domain. Configure its action to navigate to the corresponding bookmark:
- MDG button → “MDGView” bookmark
- Other domain buttons → “StandardView” bookmark
- Hide the original slicer and use the buttons as navigation controls.
Pros: No DAX required; maintains full visual formatting.
Cons: Requires duplicated visuals; less efficient for many domains. The Enterprise DNA forum discusses bookmark-based solutions for multi-domain scenarios.
Approach 3: Field Parameters / Disconnected Slicer
For advanced users, this technique uses Power BI’s Field Parameters feature (available in recent versions) to switch data sources dynamically.
Key Steps:
- Create a Field Parameter named “ChartDataSource” with two values:
- “StandardChart” →
StandardTable[Value] - “MDGChart” →
MDGTable[Value]
- “StandardChart” →
- Build a disconnected slicer from this parameter.
- Use DAX to select the correct measure:
DynamicChart_Value =
SWITCH(
SELECTEDVALUE('ChartDataSource'[ChartDataSource]),
"StandardChart", SUM(StandardTable[Value]),
"MDGChart", SUM(MDGTable[Value]),
BLANK()
)
- Apply this measure to a single bar chart.
Note: This requires Power BI Desktop November 2022 or later. RADACAD’s guide provides deeper context on parameter tables.
Implementation Checklist
-
Data Model Preparation
- Ensure both tables (standard and MDG data) have consistent date/segment dimensions.
- Verify relationships are properly configured.
-
DAX Approach Setup
- Create
[IsMDGSelected]measure. - Build conditional measures for both charts.
- Apply visual-level filters and masking cards if needed.
- Create
-
Testing
- Verify charts display correctly for all 9 domains.
- Test multi-select scenarios if applicable.
- Check performance with large datasets (use
EVALUATEATfor debugging).
-
User Experience
- Add a label showing the current domain selection.
- Consider tooltips explaining the chart switch.
Limitations and Pro Tips
- DAX Limitations: Measures with
BLANK()may cause visual headers to disappear. UseIF(ISBLANK(...), 0, ...)to retain headers. - Performance: Complex DAX can slow report refresh. Minimize context transitions by using variables:
StandardChart_Value =
VAR CurrentDomain = SELECTEDVALUE(Domain[Domain])
RETURN
IF(CurrentDomain <> "MDG", SUM(StandardTable[Value]), BLANK())
- Alternative Method: For 9 domains, consider a single dynamic measure using
SWITCHinstead of flags:
DomainSpecificChart =
SWITCH(
SELECTEDVALUE(Domain[Domain]),
"Finance", SUM(FinanceTable[Value]),
"Sell", SUM(SellTable[Value]),
// ... other domains ...
"MDG", SUM(MDGTable[Value]),
BLANK()
)
- Community Advice: Use bookmarks for KPI-heavy reports and DAX for data-heavy dashboards. The Microsoft Learn documentation emphasizes that visual interactions should be explicitly configured to avoid unintended filtering.
Sources
- Microsoft Learn. Slicers in Power BI
- MSSQLTips. Dynamically Show or Hide Power BI Visual Based on Slicer Selection
- ExceibratorBI. Show or Hide a Power BI Visual Based on Selection
- Enterprise DNA Forum. Dynamically Change Visual based on Slicer Value Selection
- RADACAD. Change the Column or Measure Value in a Power BI Visual by Selection of the Slicer
Conclusion
For your scenario—switching to a different bar chart when MDG is selected—the DAX flag and conditional measures approach is the most efficient. It dynamically controls data visibility without duplicating visuals or requiring complex UI navigation. Start with the [IsMDGSelected] measure and conditional measures for each chart, leveraging visual-level filters and masking cards as needed. This method ensures maintainability, performance, and a seamless user experience across all 9 domains while adhering to Power BI’s best practices for conditional visualization.