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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

SAMEPERIODLASTYEAR() returns incorrect result when current day is selected

Hello, 

I'm strugling with calculation of last year's bookings. I'm using the function SAMEPERIODLASTYEAR, but for some reason when current day or some future date is selected, it returns value of bookings for whole month (picture attached). When I choose yesterday's date, calculation is correct - it takes only same part of last year's month.

 

I was trying to put in the formula additional filter that limits my table 'Date - bookings' to today()-1, but without any good results. 

 

Has anybody experienced same issue?

Thank you for any suggestions.

 

Bookings USD =  SUM(contract_data[price])

 

Prior Period =
CALCULATE([Bookings]                                        
                    ,SAMEPERIODLASTYEAR('Date - bookings'[Date])
                    )
 
The Date table is calculated, relationship is 1:N and one-way:
Date - bookings =
ADDCOLUMNS (
                   CALENDAR (MIN(contract_data[booking_date]), TODAY()),
                   "Year/Month", FORMAT ( [Date], "YYYY/MM" ))
 
pbi.png
5 REPLIES 5
Anonymous
Not applicable

Do you have a dedicated date table? If so, is it marked as such?  

Anonymous
Not applicable

Hi, thanks for your reply. Yes it is marked as date table. It is calculated table as noted in my post above.

Capture.PNG

Anonymous
Not applicable

can you upload some sample data?

Anonymous
Not applicable

Hi, 

the file is here: https://gofile.io/?c=459T1J

Thanks

Anonymous
Not applicable

it's working like it is supposed to. Everything comes down to context. So when you have a date slicer that stops before the current end of the month, it will give you the total of the previous period of that same time. 

Sameperiod explanation.png

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors