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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Ben81
Helper I
Helper I

Two charts with dynamic dates

Hi, stuck with the following;

I have two YTD charts on the same page displaying the same measure that spits out a count value on a weekly axis. The first chart shows the selected year via a slicer but the other needs to show for the year previous to whatever is selected.

 

I've tried doing this by making two seperate measures and minuplating the dates based on the slicer selection but this won't work for various reasons. My other solution which isn't working is to try and add something to the filter, like a switch of 1 or0...1 being the year I want and 0 being the years to not show but I can't figure this out and get it working.

I thought I could create a calculated column in my date table that would give a 1 or 0 based on the selected slicer? I.e.

PY = 
Var _Selected = SelectedValue(Slicer)  //2023 for example
Var _PY = _Selected - 1
RETURN
If('date'[year] = _PY,1,0)

This just returns 1 for every row 😞

Any ideas? 

Thanks,
 Ben

 

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@Ben81,

 

If your primary measure is [Count], you could use the SAMEPERIODLASTYEAR function to return last year's data:

 

Count Last Year =
CALCULATE ( [Count], SAMEPERIODLASTYEAR ( DimDate[Date] ) )




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
DataInsights
Super User
Super User

@Ben81,

 

If your primary measure is [Count], you could use the SAMEPERIODLASTYEAR function to return last year's data:

 

Count Last Year =
CALCULATE ( [Count], SAMEPERIODLASTYEAR ( DimDate[Date] ) )




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Ah amazing, didn't know of that function. 

 

Thanks

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.