Forum Discussion
Dynamic Legends based hierarchy selection
Hi Ravi_G
Power BI doesn’t let you directly switch the legend column based on a slicer, which makes dynamic legends tricky. But there’s a workaround that’s worked well for me.
What I usually do is create a separate slicer table (not related to the model) that just holds the level names like “Level 1”, “Level 2”, “Level 3”. Based on what’s selected there, you can build a calculated column or measure that switches between the actual columns in your hierarchy.
Legend Label =
SWITCH(
SELECTEDVALUE(LevelSelector[Level]),
"Level 1", Table[Level2],
"Level 2", Table[Level3],
"Level 3", Table[Level4]
)
Then you use this Legend Label as the legend in your chart. It’s not truly dynamic in the sense of changing the metadata of the chart, but it gets the job done visually.
Just be aware that this works best when your hierarchy is flattened (i.e. columns for each level). If you're using a parent-child hierarchy, it’ll need a slightly different setup.
Hi Ravi_G ,
Hi there, just following up on your query about Dynamic Legends based hierarchy selection. rohit1991 has provided a response that may address your concern.
If his solution worked for you, please consider marking it as the Accepted Answer — this helps others in the community who might have the same question.
If you're still experiencing issues or need further clarification, feel free to add more details — we’re here to help!
Thanks again for being part of the Microsoft Fabric Community!