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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ovonel
Post Prodigy
Post Prodigy

How To Use Filters As legends?

I have my clustered column chart working just fine!

 

I have my Rev and Rev SamePeriodLastYear measures.

ovonel_0-1672929811402.png

 

 

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

 

And then I just play with my filter YEAR:

ovonel_1-1672929832302.png

 

 

 

It works fine, my issue is with the legends.  It is not very nice seeing this legend:

ovonel_2-1672929842473.png

 

 

I want to see as legend;         2023   2022   (when 2023 is selected) and         2022   2021  (when 2022 is selected).

 

Is this even possible?

 

thanks.

 

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

Hi @ovonel ,

 

You can put your fiscal year field into Legend and create a measure to return the revenue for the selected year and revenue for the previous year in the selected year.

Sample data

vstephenmsft_1-1673332242281.png

 

For the slicer, you fiscal year field should come from a separate table, not related to the main table or the calendar table.

Year for slicer = DISTINCT('Table'[Year])

vstephenmsft_0-1673332233210.png

Create a measure like this.

Measure = CALCULATE(SUM('Table'[Rev]),FILTER('Table',[Year]=SELECTEDVALUE('Year for slicer'[Year])||[Year]=SELECTEDVALUE('Year for slicer'[Year])-1))

The year of the slicer is from table [Year for slicer]. The result is as follows.

vstephenmsft_2-1673332273754.png

 

 

Best Regards,

Stephen Tao

 

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-stephen-msft
Community Support
Community Support

Hi @ovonel ,

 

You can put your fiscal year field into Legend and create a measure to return the revenue for the selected year and revenue for the previous year in the selected year.

Sample data

vstephenmsft_1-1673332242281.png

 

For the slicer, you fiscal year field should come from a separate table, not related to the main table or the calendar table.

Year for slicer = DISTINCT('Table'[Year])

vstephenmsft_0-1673332233210.png

Create a measure like this.

Measure = CALCULATE(SUM('Table'[Rev]),FILTER('Table',[Year]=SELECTEDVALUE('Year for slicer'[Year])||[Year]=SELECTEDVALUE('Year for slicer'[Year])-1))

The year of the slicer is from table [Year for slicer]. The result is as follows.

vstephenmsft_2-1673332273754.png

 

 

Best Regards,

Stephen Tao

 

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 , for that you have two use an independent date/Year slicer and use measure like

 

example

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

 

Need of an Independent Table in Power BI - Exclude: https://youtu.be/lOEW-YUrAbE

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.