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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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, @Anonymous 

 

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
Super User

@Anonymous 

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!


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as 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 C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

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.

AllisonKennedy
Super User
Super User

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? 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as 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 C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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