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

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

Reply
dataandme
Frequent Visitor

Leap Year issue with SAMEPERIODLASTYEAR

Hi,
Im new to Power BI and DAX. Really appreciate for some help. I used SAMEPERIODLASTYEAR function to refer back to the Sales Last Year. But Im getting the 28th Feb 2023 sales value reflected as last year's sales for 29th Feb 2024 even though the day 29th Feb 2023 doesnot exists. Is there a work around this to display that value blank when such dates doesnot exists?unnamed (1).png


Thanks in advance.

4 REPLIES 4
raji_n
Resolver II
Resolver II

@dataandme this is the expected behaviour, sameperiodlastyear compares day with day hence 29th is considered, please refer this DAX to handle 29th data,

Sales PY :=
if( hasonevalue(DateDimension[Date]),
var __currentDate = max(DateDimension[Date])
var __shouldCalculate =
month(__currentDate) <> 2
&& day(__currentDate) <> 29
var __result =
if(__shouldCalculate,
CALCULATE(
[System Sales],
DATEADD(DateDimension[Date],-1,YEAR)
)
)
return
__result
)

Hi @raji_n,
Thank you for the DAX, but now the entire month of Feb is vanishing rather than just 29th Feb.

unnamed2.jpg

@dataandme try =2 instead of <>2 in the DAX, my bad, sorry!

 

Hi @raji_n 
Now, its skipping 29 Feb 2024 which is good but giving me only the PY Sales for Feb. 

unnamed (1).png

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.