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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
wmorris20
Helper II
Helper II

Alternative for SAMEPERIODLASTYEAR()

We are looking to generate forecasts based on the prior year.  SAMEPREIODLASTYEAR works fantastic until you get to a future month.  I'd prefer not to insert blank future records in order to "fix" the problem, so I was wondering if there was an alternative to coming up with PY Sales:

 

PY Sales Dollars = CALCULATE([Sales Dollars],SAMEPERIODLASTYEAR('Sales'[Date]), ALL('Time'))

 

 

Thanks!

1 ACCEPTED SOLUTION

I see what it is.  You have to use the 'Time' dimension's date field in your SAMEPERIODLASTYEAR call, not the 'Sales' table which won't have values for the future dates.  And you don't need that ALL('Time') filter:

 

PY Sales Dollars = CALCULATE([Sales Dollars],SAMEPERIODLASTYEAR('Time'[Date]))

This assumes your date field that you join on is 'Time'[Date], adjust accordingly if it's not.

View solution in original post

6 REPLIES 6
bblais
Resolver III
Resolver III

I think you will need to insert records into your 'Time' table for the future dates no matter what the solution, as any visuals you create will not just come up with the future dates for you.  If you do this, doesn't the PY Sales Dollars show up for future periods even if the current year Sales are blank?

I do have future dates for the Time dimension, but the lack of actuals in the current year are preventing this function from working for the future months.

Here's an example of it working for me:

 

I have a Revenue measure:

 

Revenue = SUM(Sales[Order Revenue])

Then I have an LY Revenue measure:

 

LY Revenue = CALCULATE([Revenue],SAMEPERIODLASTYEAR('Calendar'[Date])

I have data going through the end of March 2017 in my sales data, but I have entries in my 'Calendar' table all the way through to the end of 2017.  When I create a table with Date, Revenue and LY Revenue, the LY Revenue continues to populate for future dates even though there is no current date data available for that period:

 

Capture.PNG

 

It works with different granularities or in other visuals as well:

 

Capture.PNG

I see what it is.  You have to use the 'Time' dimension's date field in your SAMEPERIODLASTYEAR call, not the 'Sales' table which won't have values for the future dates.  And you don't need that ALL('Time') filter:

 

PY Sales Dollars = CALCULATE([Sales Dollars],SAMEPERIODLASTYEAR('Time'[Date]))

This assumes your date field that you join on is 'Time'[Date], adjust accordingly if it's not.

Thank you!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.