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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
imranami
Helper I
Helper I

SAMEPERIODLASTYEAR for Fiscal year

Hello. I have a Date table with a one to many join to a date field in a sales table. The Date table has a column which identifies the correct financial year for each date (FY18, FY19, FY20). The financial year is 31st  March to the 1st April.

 

Depending on the financial year selected from a slicer, I need a visual to display sales data for the selected financial year as well as the previous financial year (if a user selects FY19, they should also see data for FY18).

 

I was previously SAMEPERIODLASTYEAR using until I realised this measure was calculating by calendar year rather than fiscal year.

 

Total Value Previous Year =
CALCULATE(
    [Total Sales] ,
        SAMEPERIODLASTYEAR( Dates[Date]))

 

 

 

This is a common problem within the community forums but I cannot seem to identify the correct solution for my scenario. Any support would be appreciated.

Capture.PNG

regards,

ImranAmi

1 ACCEPTED SOLUTION
imranami
Helper I
Helper I

Looks the guidance provided in this article has resolved the issue using the below article (Russo & Ferrari).

 

https://www.daxpatterns.com/time-patterns/

 

Added an additional date column to my table which subtracts the current date by one year:

PY Date = DATE(YEAR(Dates[Date])-1,MONTH(Dates[Date]),DAY(Dates[Date]))

Then used the following DAX to return the sales amount from the previous year:
 
Total Value Previous Year =
CALCULATE (
[Total Sales],
FILTER (
ALL ( Dates ),
Dates[Year] = MAX ( Dates[Year])-1
&& Dates[Date] <= MAX ( Dates[PY Date] )
))

View solution in original post

2 REPLIES 2
imranami
Helper I
Helper I

Looks the guidance provided in this article has resolved the issue using the below article (Russo & Ferrari).

 

https://www.daxpatterns.com/time-patterns/

 

Added an additional date column to my table which subtracts the current date by one year:

PY Date = DATE(YEAR(Dates[Date])-1,MONTH(Dates[Date]),DAY(Dates[Date]))

Then used the following DAX to return the sales amount from the previous year:
 
Total Value Previous Year =
CALCULATE (
[Total Sales],
FILTER (
ALL ( Dates ),
Dates[Year] = MAX ( Dates[Year])-1
&& Dates[Date] <= MAX ( Dates[PY Date] )
))

Great solution, thank you!

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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