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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
aalamos
Frequent Visitor

Problem with SAMEPERIODLASTYEAR

Hi, Im having a problem with the calculation made by SAMEPERIODLASTYEAR,  but this problem does not happens using it twice to get the last last year calculation:

 

aalamos_0-1626109461828.png

 

As you can see, the LY Revenue total calculation is absolutely wrong and I can not get why.

 

LY Revenue =
CALCULATE(SUM('Sales'[total]), SAMEPERIODLASTYEAR('Calendar'[Date]))
 
LLY Revenue = CALCULATE(SUM('Sales'[total]), SAMEPERIODLASTYEAR(SAMEPERIODLASTYEAR('Calendar'[Date])))

 

Thanks in advance

3 REPLIES 3
amitchandak
Super User
Super User

@aalamos , Try trailing year measure

LY Revenue =
CALCULATE(SUM('Sales'[total]), dateadd('Calendar'[Date],-1, year))

 

LLY Revenue =

CALCULATE(SUM('Sales'[total]), dateadd('Calendar'[Date],-2, year))

 

or try

LLY Revenue = CALCULATE(SUM('Sales'[total]), SAMEPERIODLASTYEAR(dateadd('Calendar'[Date],-1,year)))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi,

 

I tried your solution but I have the following issue that is the same using SAMEPERIODLASTYEAR:

 

As you can see, if I use an advanced filter on the date slicer using date is "on or after" 01-01-2021 the calculation is correctly done:

 

aalamos_0-1626115186463.png

BUT,  if I move the slicer to any other data range and then I move it back to the same range (01-01-2021 / 11-07-2021) the sum calculation is messed up again:

 

aalamos_1-1626115253279.png

 

Thanks in advance for your time

Hi,  @aalamos 

From your current formula, I did not find any error, maybe you need to  manually  filter the year in  table visual filter pane.

7.png

 

If I misunderstood, please explain it in more detail and share your sample files for further research.

 

Best Regards,
Community Support Team _ Eason
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 is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.