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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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.




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:



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




Any idea?



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



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

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.