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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Botturovic
Frequent Visitor

Problem with "sameperiodlastyear" function

 

i'm trying to compare sales of two different years by different categories.
I've created two measures: Total Amount YTD  e Total Amount YTD last year.

 

prob1.jpg

 

When i try to insert the second measure "YTD Last Year" in the table Powerbi give me an error and i can't understand what's wrong.

Here is the formula of the measure:

prob2.png

 

If i try to insert the measure in a new table it works, but if i try to insert the category table it stops working.
So the problem must be somehow with the category table, but i don't have any problem with that table in the measure YTD

 

prob4.png

 

Any idea?

Thanks

1 REPLY 1
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Botturovic,

 

What is the error message under measure formula and the error message shown in visual?

 

Did you have a calendar table? I think you should refer to a date field from calendar table in SAMEPERIODLASTYEAR function.

 

Here are some similar examples for your reference:

SAMEPERIODLASTYEAR – comparison with previous year (DAX – Power Pivot, Power BI)

Get the YTD of same period last year using DAX

 

Regards,

Yuliana Gu

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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors