Forum Discussion
Dynamic Legends based hierarchy selection
Hey there!
Hereโs how you can achieve that using DAX measures and potentially slicers or selection controls in Power BI:
Create a Dynamic Measure for Line Chart: You'll need a dynamic DAX measure that changes its behavior based on the selected level from the matrix. For example, you can use a measure like this:
DynamicLevelMeasure =
SWITCH(
TRUE(),
SELECTEDVALUE('Hierarchy'[Level]) = 1, SUM('Data'[Level1Amount]),
SELECTEDVALUE('Hierarchy'[Level]) = 2, SUM('Data'[Level2Amount]),
SELECTEDVALUE('Hierarchy'[Level]) = 3, SUM('Data'[Level3Amount]),
SELECTEDVALUE('Hierarchy'[Level]) = 4, SUM('Data'[Level4Amount])
)
You can add a slicer or matrix to allow users to select which level they want to display. The slicer will control which level the line chart visual shows.
Create a line chart and add the DynamicLevelMeasure as the value.
For the x-axis, you can use a time-based or sequential field (e.g., a date or period column).
Ensure that the slicer (or matrix) that controls the level is properly interacting with the line chart. You can adjust the interactions via the Format pane in Power BI to control how selections in the matrix or slicer affect the line chart.
Hope this helps!
๐๐
- Ravi_G1 year agoNew Member
Thank you for the reply ..i want claculated column that i need to place in Legend of line chart. and how we are assigning 1 to level SELECTEDVALUE('Hierarchy'[Level]) = 1 in above measure using parameters?