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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
rickylee
Helper III
Helper III

SAMEPERIODLASTYEAR does not work as expected

Hello,

I am trying to use the SAMEPERIODLASTYEAR formula but it seems it does not work as it is. 

Last year revenue2a = CALCULATE(sum('Revenue 2017 18'[Total]),SAMEPERIODLASTYEAR('Calendar'[Date]))

 

 

The relationship between 'Calendar' table and 'Revenue 2017 18' can be seen below:

powerbi relationship.png

 

The calendar table has one formula only: 
Calendar = CALENDARAUTO(3)

table - calendar.png

The 'revenue 2017 18' table has 12 rows of data only:
table - revenue 2017 18.png

 

When I try to display the thidd column which has the formula:
"Last year revenue2a = CALCULATE(sum('Revenue 2017 18'[Total]),SAMEPERIODLASTYEAR('Calendar'[Date]))"
The column displays data in 2019 which I don't have such data at all. 
output.png

 

Did I do anything wrong?

Thanks,
Ricky

5 REPLIES 5
rickylee
Helper III
Helper III

@v-danhe-msft

Hello, it does not work for me as such but  I manually created an alternative solution. It does not use the function which is not ideal.

Thanks,
Ricky

v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @rickylee,

Could you please tell me if your problem has been solved? If it is, could you please mark the helpful replies as Answered?

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
rickylee
Helper III
Helper III

*I have posted the following before but it did not exist in my subscription. So I re-post again.

 

Hello,

I am trying to use the SAMEPERIODLASTYEAR formula but it seems it does not work as it is. 

Last year revenue2a = CALCULATE(sum('Revenue 2017 18'[Total]),SAMEPERIODLASTYEAR('Calendar'[Date]))

 

 

The relationship between 'Calendar' table and 'Revenue 2017 18' can be seen below:

powerbi relationship.png

 

The calendar table has one formula only: 
Calendar = CALENDARAUTO(3)

table - calendar.png

The 'revenue 2017 18' table has 12 rows of data only:
table - revenue 2017 18.png

 

When I try to display the thidd column which has the formula:
"Last year revenue2a = CALCULATE(sum('Revenue 2017 18'[Total]),SAMEPERIODLASTYEAR('Calendar'[Date]))"
The column displays data in 2019 which I don't have such data at all. 
output.png

 

Did I do anything wrong?

Thanks,
Ricky

Hi @rickylee,

Could you have received the reply I sent to you before? And have you tetsed to modify your calendar table like this?

Table = CALENDAR("2017/1/1","2018/12/31")

 

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @rickylee,

Based on my test, this is due to your calendar table contains the date in 2019, you could modify your calendar table like this:

Table = CALENDAR("2017/1/1","2018/12/31")

And now you could get the correct result:

1.PNG

You can also download the PBIX file to have a view.

 https://www.dropbox.com/s/jiyrv4foti2m85a/SAMEPERIODLASTYEAR%20does%20not%20work%20as%20expected.pbi...

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors