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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
RingoSun
Helper II
Helper II

Dynamic Legend Name

So I have this visual right here. The Actual Current Year and Target Current Year are actually two separate measures used as the X-axis

RingoSun_1-1660498487684.png

Now, I want to make the Target Current Year measure dynamic. I want to be able to switch between Target Current Year and Actual Last Year. So to do this I'll modify the measure into:

Measure =
VAR Selection = SELECTEDVALUE(Slicer[Value])
RETURN
SWITCH(
   TRUE(),
   Selection = 'Target Current Year', [TargetCY],
   Selection = 'Actual Last Year', [ActualLY]
)

Now I am able to dynamically change measures but the issue is that the legend name will not be changing along with it. So is there any way to dynamically change the legend name as well? If I select "Target Current Year" in slicer then the legend name should be Target Current Year and vice versa.

 

How do I achieve this without using bookmarks?

1 ACCEPTED SOLUTION
OzkanDhont
Resolver II
Resolver II

Hi @RingoSun !

 

I would recommend using the new field parameter feature.

Go to Modeling > New Parameter > Fields > Select the measures you need, [TargetCY] and [ActualLY].

Apply the newly created Parameter in your visuals instead of the two measures and apply the parameter to your slicer aswell.

 

Field parameters: https://www.youtube.com/watch?v=LTdpe2ENW4M&t=375s

 

Hope it helps!

 

Kind regards,

OD

View solution in original post

3 REPLIES 3
OzkanDhont
Resolver II
Resolver II

Hi @RingoSun !

 

I would recommend using the new field parameter feature.

Go to Modeling > New Parameter > Fields > Select the measures you need, [TargetCY] and [ActualLY].

Apply the newly created Parameter in your visuals instead of the two measures and apply the parameter to your slicer aswell.

 

Field parameters: https://www.youtube.com/watch?v=LTdpe2ENW4M&t=375s

 

Hope it helps!

 

Kind regards,

OD

Hi, 
I kind of have a similar problem and was wondering if you know the answer. I have used a line and clustered column chart where I plot the time series data for two quarters based on the selection from the slicer and then the difference between them as bars. I want that whichever quartes are selected from the slicer should be displayed as the legend of the chart but can't figure out how I can achieve that.

So in this image posted below you can see that instead of Release1 and Release2 I want to display the name of the quarters that are selected. I cannot pass these names through a measure because the chart allows only column legend and nothing for lines. I cannot set the variable name to change dynamically.Problem image.PNG

speedramps
Super User
Super User

Consider using the new Power BI Fied parameter feature ...

 

https://docs.microsoft.com/en-us/power-bi/create-reports/power-bi-field-parameters

 

Thanks for reaching out for help.

I put in a lot of effort to help you, now please quickly help me by giving kudos.

Remeber we are unpaid volunteers and here to coach you with Power BI and DAX skills and techniques, not do the users job for them. So please click the thumbs up and accept as solution button. 

If you give someone a fish then you only give them one meal, but if you teach them how to fish then they can feed themselves and teach others for a lifetime.  I prefer to teach members on this forum techniques rather give full solutions and do their job. You can then adapt the technique for your solution, learn some DAX skills for next time and soon become a Power BI Super User like me. 

One question per ticket please. If you need to extend your request then please raise a new ticket.

You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.