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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
ovonel
Post Prodigy
Post Prodigy

Is it possible to use a dynamic value as legend?

I have my clustered column chart working just fine, with Rev and Rev SamePeriodLastYear.

 

Measures:

ovonel_0-1672991846937.png

 

(Rev is just a sum… and the other measure uses the function SAMEPERIODLASTYEAR.)

 

 

In my report I use the YEAR filter:

ovonel_1-1672991880023.png

 

 

 

It works fine, my issue is with my legends:

ovonel_2-1672991898504.png

 

 

I want to see as legend; 2023 2022 (when 2023 is selected) and 2022 2021 (when 2022 is selected). (or at least static/generic like "selected year" "previous year")

 

Is this even possible? The legend section doesn't have a 'function' option to make it dynamic

 

 

 

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

Hi @ovonel ,

 

Here I create a sample to have a test. In my sample, data is from 2020/01/01 to 2023/01/09. I suggest you to create an unrelated DimYear table to create the slicer. My data model is as below.

RicoZhou_0-1673255200326.png

Measure:

Rev = 
VAR _SELECT =
    SELECTEDVALUE ( SelectYear[Year] )
RETURN
    IF (
        SELECTEDVALUE ( DimDate[Year] )
            IN { _SELECT, _SELECT - 1 },
        SUM ( 'Table'[Value] )
    )

Result is as below.

RicoZhou_1-1673255292980.png

 

Best Regards,
Rico Zhou

 

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

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @ovonel ,

 

Here I create a sample to have a test. In my sample, data is from 2020/01/01 to 2023/01/09. I suggest you to create an unrelated DimYear table to create the slicer. My data model is as below.

RicoZhou_0-1673255200326.png

Measure:

Rev = 
VAR _SELECT =
    SELECTEDVALUE ( SelectYear[Year] )
RETURN
    IF (
        SELECTEDVALUE ( DimDate[Year] )
            IN { _SELECT, _SELECT - 1 },
        SUM ( 'Table'[Value] )
    )

Result is as below.

RicoZhou_1-1673255292980.png

 

Best Regards,
Rico Zhou

 

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

 

amitchandak
Super User
Super User

@ovonel , I doubt rename measure dynamically, What You can try is have a slicer on an independent table

 

try like

 

//Date1 is independent Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Year])
var _min = _max -1
return
calculate( sum(Table[Value]), filter('Date', 'Date'[Year] >=_min && 'Date'[Year] <=_max))

 

 

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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