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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Unable to calculate previous year FY values using SAMEPERIODLASTYEAR

Dear Expertise,

I am new to Power BI. Our fiscal year starts from October to September. I have to compare sales of current fiscal year with sales of previous financial year. I am writing the formula as PrevRev=CALCULATE(SUM('Sales Table'[Sales]),SAMEPERIODLASTYEAR(DateTime[DateTime].[Date])). But is calculating wrongly, it is showing values as current fiscal year.I am missing someting. Please help me .I have uploaded my pbix file for your reference. Thank you.

https://drive.google.com/file/d/1gSTBdH_QTTJi-2AIuX12ZnHdJauB_SCY/view?usp=sharing

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Funny enough the "Time Intelligence" functions actually require a Dates table.  Your table is too granular (including hours), and the date column is not marked correctly.

 

Dates = CALENDARAUTO(9)

Fiscal Year = CONCATENATE("FY",IF(MONTH(Dates[Date])<=9,YEAR(Dates[Date])-1,YEAR(Dates[Date])))

 

lbendlin_1-1597613259551.png

 

In addition your contract date needs to be mapped to a Date type column, and that column then used in the data model.

 

lbendlin_2-1597613316005.png

 

Then everything works as you intended.

 

 

lbendlin_0-1597613137815.png

 

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , Do not use .date.

 

In case you have datetime, in your table. Create a date column

Date = [Datetime].Date.

Join this with date table and then use time intelligence function. Date/calendar table should be marked as a date table. Option on Right-click.

 

Depending on the need you can use SAMEPERIODLASTYEAR or following

 

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
This year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Last to last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-2,Year),"12/31"))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
//Only year vs Year, not a level below

This Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))

 

 

Power BI — YTD
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184


Appreciate your Kudos.

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
lbendlin
Super User
Super User

Funny enough the "Time Intelligence" functions actually require a Dates table.  Your table is too granular (including hours), and the date column is not marked correctly.

 

Dates = CALENDARAUTO(9)

Fiscal Year = CONCATENATE("FY",IF(MONTH(Dates[Date])<=9,YEAR(Dates[Date])-1,YEAR(Dates[Date])))

 

lbendlin_1-1597613259551.png

 

In addition your contract date needs to be mapped to a Date type column, and that column then used in the data model.

 

lbendlin_2-1597613316005.png

 

Then everything works as you intended.

 

 

lbendlin_0-1597613137815.png

 

Anonymous
Not applicable

Many thanks !

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