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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
bignadad
Helper I
Helper I

SAMEPERIODLASTYEAR not returning correct values with fiscal year

My fiscal year is April-March

I have the Fiscal Year setup correctly in my MasterDate table.

I have a Fiscal Year Text that I use for my Slicer and a Fiscal Year Sort to sort properly.

All that is working fine.

bignadad_0-1706295041965.png

This is my measure to get my total amount

Total = CALCULATE(SUM(glentry[amount])*-1)
 
I have my Slicer filtering for FY23/24 and my total is correct
bignadad_2-1706295199958.png

 

My LY measure is not correct. Here is the measure.

LY Sales = CALCULATE(glentry[Total], SAMEPERIODLASTYEAR(MasterDate[Dates].[Date]))
 
Any idea what I'm doing wrong?
9 REPLIES 9
bignadad
Helper I
Helper I

I am pretty new to power bi and not sure how to create the pbix file with sample data. Right now all my data is set up is on dataflows. how can I get them to local sample data?

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

lbendlin
Super User
Super User

How do you know it is not correct?

@lbendlin my assumption about SAMEPERIODLASTYEAR is that the fiscal year starts in April, and traditional time intelligence functions often align with the calendar year.

SAMEPERIODLASTYEAR can be useful in this case if the MasterDate table is correctly set up & marked as a dateTable.

 

I suggest using DATESYTD or ash coding because there are other ways to achieve the same result.

What are your suggestions? Please advise

Thanks
Dallas

@DallasBaba SAMEPERIODLASTYEAR is syntax suggar for DATEADD(-1,YEAR), and it works as long as your fiscal years start on the same day.  For other cases like fiscal week driven fiscal years this won't work, and you will need to compute based on the period indicators in the calendar table.

@lbendlin  Thank you for the clarity.

Thanks
Dallas
DallasBaba
Skilled Sharer
Skilled Sharer

@bignadadThe SAMEPERIODLASTYEAR function may not work as expected because it operates based on calendar years. You can try ash coding:

LY Sales = CALCULATE(
    glentry[Total],
    DATEADD(
        VALUES(MasterDate[Dates].[Date]),
        -1,
        YEAR
    )
)

 

OR try using the DATESYTD function. 

LY Sales = CALCULATE(glentry[Total], DATESYTD(PARALLELPERIOD(MasterDate[Dates].[Date], 1, "Year")))

This measure will calculate the sales for the previous fiscal year based on the date selected in your slicer. Please note that the DATESYTD function returns the year-to-date total for the given date, so you don’t need to use the TOTALYTD function. 

 

Let me know if this works for you. @ me in replies, or I'll lose your thread!!!  
Note:
If this post is helpful, please mark it as the solution to help others find it easily. Also, if my answers contribute to a solution, show your appreciation by giving it a thumbs up
Thanks
Dallas

I tried both but its still not giving the correct data

bignadad_1-1706307211140.png

I labeled the column names with your two suggestions

 

I have another page where i am manually selecting the dates and the total should be 2,636,714 for LY (April 2022 - March 2023)

bignadad_2-1706307293929.png

@bignadad can you share a pbix file with sample data? 

Thanks
Dallas

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.