Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
iago_salvadori1
Frequent Visitor

Dynamically legend

Hello everyone,

 

We build a schema for analysis any measures in the same sheet

Measure = 
VAR Logic Test = 
COUNTROWS(DISTINCT(FILTER(ALLSELECTED('KPI´s'[KPI]),'KPI´s'[KPI] = "Real Sales"))) = 1 
RETURN 
IF(LogicTest, [Real_Sale],blank())

We utilize the visualization Line and Clustered column charts, in shared axis we have month and column values we have 4 measures (Real sales, Planned Sales,(...)).

 

Our problem is, when for example we selected only measure (Real Sales) the graph value appear correctly but the legend appear all measures (not selected in filter).

 

Is there any way for the legend graph to be dynamic? Or create a outside legend the chart?

 

Thank you.

5 REPLIES 5
NidhiBhusari
Helper IV
Helper IV

@iago_salvadori1 
Follow below steps to get dynamic legends:-

1) Open the data table in Power query adn DUPLICATE it and rename the other table.
2)Remove the unwanted columns from table.
3)Add index to both tables(Original Table and Duplicate table).

NidhiBhusari_1-1624037332277.png


4)Select and unpivot the columns that you want to display dynamically as legend.
NidhiBhusari_2-1624037418412.png

5)After unpivoting you will get two new columns having ATTRIBUTE and VALUE

NidhiBhusari_0-1624037273535.png
6) Save and close power query.

7)In Model view tab, create relationship between Original Table and New unpivot table on Index column.

😎 Now you can put the ATTRIBUTE column from new table(on which we have done unpivoting) in column series of clustered chart.

NidhiBhusari_3-1624037970289.png

 

NidhiBhusari_4-1624037999692.png

 

 

Anonymous
Not applicable

Do we have any solution to this requirement?

Hi @NidhiBhusari , thank you suggestion.

 

But I don´t understand why I have create a index.

 

I will try to explain myself better:

 

I have two tables in my model, one table (Table1) I have all data what I need and another table (Table2) I created for select all measures in one sheet:

Table2

iago_salvadori1_0-1624039181180.png

For example:

Vendas Reais = 
VAR Logic Test = 
COUNTROWS(DISTINCT(FILTER(ALLSELECTED('KPI´s'[KPI]),'KPI´s'[KPI] = " Vendas Reais"))) = 1 
RETURN 
IF(LogicTest, [Real_Sale],blank())

The measure [Real_sale] is calculated in Table1.

 

When we selected in filter a measure the legend graph appear all measures (not selected in filter).

iago_salvadori1_1-1624039488135.png

We want the legend visualizations to show only the measures that are selected.

 

Thank you.

Thank you for this, worked perfectly on my own health data - where I wanted to have the Column Series switch between Episode of Care, Admission Category, Gender and I even added Ward to see how well it worked. Perfect!

 

Saved me hours of time running bookmarks etc!

 

🙂

 

Regards

ClinEpi

Hi @iago_salvadori1 !

Please try changing teh slicer type to be single select & see if that make any difference.

 

Regards,

Hasham

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.