To create a donut chart that updates dynamically with user-selected dimensions in Power BI, carry out the following steps:
1. Create a Field Parameter for Dynamic Dimensions
These Field Parameters allow users to switch between different segment categories dynamically.
Go to Power BI Desktop > Modeling > New Parameter > Fields and create it.
Name it Segment Selector and add the dimensions you need users to toggle:
- Region
- Product Category
- Sales Channel
Enable the add slicer option on this page.
This creates a new table in which selected fields are found, thus enabling users to switch dimensions dynamically.
2. Add Field Parameter in the Donut Chart
Add the Segment Selector field to the Legend in the donut chart.
Use Sales Amount or any other measure for this Values section. The segments of the chart will be updated according to the user's selection through the slicer with the corresponding dimension.
3. Ensure Proper Aggregation Using DAX
If required, create dynamic measures to ensure all calculations are done correctly:
DynamicSales =
CALCULATE(
SUM('Sales'[SalesAmount]),
ALLSELECTED('Segment Selector')
)
This ensures that the data aggregates correctly based on the selected dimension.
4. Test the Interaction
When users select different dimensions in the slicer, the donut chart will automatically update its segments, providing an interactive and flexible visualization.