Forum Discussion
Need Help: Multiple/Dynamic Legend in Bar chart for survey data
- 6 years ago
gt2904 - There are three general approaches to this. One can be found here and involves a very specific way of modeling your data. https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-EVERYTHING-measures-axis-legend-titles-chart-types/m-p/1027881#M444
Another is to use bookmarks, which you don't want.
The third would be to build the switching logic into your measure(s) and use the disconnected table trick. In general, to use a measure in that way, you need to use the Disconnected Table Trick as this article demonstrates: https://community.powerbi.com/t5/Community-Blog/Solving-Attendance-with-the-Disconnected-Table-Trick/ba-p/279563
So, in your case, you would have a table for your legend like:
Slicer Group Age 0-18 Age 19-blah Age blah-blah Country UK Country US You could build this disconnected table very easily with DAX using DISTINCT and such. Anyway, your slicer would slice on the slicer column and your legend would be the Group column. But, since it is a disconnected table, you would need to write your measures such that they formed the relationship between your fact table and this disconnected table.
gt2904 , refer if this can help
https://prathy.com/2018/12/dynamic-legend-in-power-bi-visual-linechart/