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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
mikelee1701
Helper III
Helper III

Adjustable Same Periodlastyear function?

HI,

 

I am using the function 'Sameperiodlastyear' and I know about 'dateadd'

 

I have a chart that looks like this:

Screenshot_021621_051401_PM.jpg

 

However, my issue is that Thanksgiving falls on a different days of the year, so things can get skewed.  I can't compare Nov 28 to Nov 28 for example.  I need to be able to compate Nov 26 to Nov 28.  I know I can use dateadd to move up or down a day or so, but I would like a slicer(or something) that will allow a user to dynamically shift those days so that we are comparing Thanksgiving day to Thanksgiving day.

 

Any ideas out there?   I have some other slicers set up, while summing works great, it starts falling apart when I want to see day to day comparisons.

 

TIA,

MIke

3 REPLIES 3
mahoneypat
Microsoft Employee
Microsoft Employee

You could make a disconnected table with GENERATESERIES(-10,10,1), for example and use the Value column from that in a slicer as your # of days to offset.  You can then use EDATE(MIN(Date[Date]), -12) + SELECTEDVALUE(Offset[Value]) in a variable for your min date, do the same for max date and use those two variables in your CALCULATE filters to get the same period last year w/o time intelligence.

 

Or you could wrap SAMEPERIODLASTYEAR with DATEADD and use the SELECTEDVALUE as the days to offset in DATESADD.

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi,

 

Ok, I created this:

testvalLY = DATEADD(SAMEPERIODLASTYEAR('SP_SRT chart'[Date]),SELECTEDVALUE(DayOffset[Day]),DAY)
 
then I created a table called 'DayOffset' with the values -5,-4,-3,-2,-1,0,1,2,3,4,5
 
Then I created a slicer so I can pick the above numbers.  But the dates are staying the same.  
 
I dropped in another table to see my day are indeed changing.
Screenshot_021721_052624_PM.jpg
What am I missing?
 
TIA,
Mike

Ok, thank you... let me give it a shot....I don't consider myself a Dax Pro. 😅

Helpful resources

Announcements
FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.