cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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

Accepted Solutions
Highlighted
Resolver III
Resolver III

Re: Alternative for SAMEPERIODLASTYEAR()

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
Highlighted
Resolver III
Resolver III

Re: Alternative for SAMEPERIODLASTYEAR()

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?

Highlighted
Helper II
Helper II

Re: Alternative for SAMEPERIODLASTYEAR()

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.

Highlighted
Resolver III
Resolver III

Re: Alternative for SAMEPERIODLASTYEAR()

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

 

Highlighted
Resolver III
Resolver III

Re: Alternative for SAMEPERIODLASTYEAR()

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

 

Capture.PNG

Highlighted
Resolver III
Resolver III

Re: Alternative for SAMEPERIODLASTYEAR()

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

Highlighted
Helper II
Helper II

Re: Alternative for SAMEPERIODLASTYEAR()

Thank you!

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors