cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rick_ferreira
Helper II
Helper II

To Change the legend according to slicer

Hi,

I have two measures and slicer, but i need to change the legend to value in the slicer.
I have this.

Rick_ferreira_0-1610740525611.png

 I wanted, if i change slicer, the value of legend also changed. 

Rick_ferreira_1-1610740644894.png

 Someone know if it is possible to changed the legend?

Thanks

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @Rick_ferreira 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end, You may try the following two ways to see if they meet your requirements.

Method1:

Table:

j1.png

 

Slicer:

j2.png

 

You may create four meausres as below.

Measure 1 = 
IF(
    "Measure 1" in DISTINCT(Slicer[Measures]),
    SUM('Table'[V1])
)
Measure 2 = 
IF(
    "Measure 2" in DISTINCT(Slicer[Measures]),
    SUM('Table'[V2])
)
Measure 3 = 
IF(
    "Measure 3" in DISTINCT(Slicer[Measures]),
    SUM('Table'[V3])
)
Measure 4 = 
IF(
    "Measure 4" in DISTINCT(Slicer[Measures]),
    SUM('Table'[V4])
)

 

Result:

j3.png

 

Method 2:

You may go to Power Query, unpivot 'V1', "V2", "V3", "V4".

Table 2:

j4.png

 

Then you may use "Attribute" to filter the result.

j5.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
AllisonKennedy
Super User III
Super User III

@Rick_ferreira 

Sorry, did I misunderstand your question - I thought you wanted the legend (which you underlined in screenshot) to change with the slicer (in other words only show the value for measure that has been selected).

 

In any case, glad you found a solution!



Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 


If you found this post helpful, please give Kudos. ?


I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 


www.excelwithallison.com

v-alq-msft
Community Support
Community Support

Hi, @Rick_ferreira 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end, You may try the following two ways to see if they meet your requirements.

Method1:

Table:

j1.png

 

Slicer:

j2.png

 

You may create four meausres as below.

Measure 1 = 
IF(
    "Measure 1" in DISTINCT(Slicer[Measures]),
    SUM('Table'[V1])
)
Measure 2 = 
IF(
    "Measure 2" in DISTINCT(Slicer[Measures]),
    SUM('Table'[V2])
)
Measure 3 = 
IF(
    "Measure 3" in DISTINCT(Slicer[Measures]),
    SUM('Table'[V3])
)
Measure 4 = 
IF(
    "Measure 4" in DISTINCT(Slicer[Measures]),
    SUM('Table'[V4])
)

 

Result:

j3.png

 

Method 2:

You may go to Power Query, unpivot 'V1', "V2", "V3", "V4".

Table 2:

j4.png

 

Then you may use "Attribute" to filter the result.

j5.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

AllisonKennedy
Super User III
Super User III

I need a little bit more info about what you're using in the chart, but I don't know of a way to change the legend. You could change the title dynamically to show what's being displayed? Or turn off the legend and have another visual that acts as the legend? 



Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 


If you found this post helpful, please give Kudos. ?


I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 


www.excelwithallison.com

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are You Ready?

Test your skills now with the Cloud Skills Challenge.

Top Solution Authors