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
Anonymous
Not applicable

DAX DateAdd in Power BI

Hi all,

I need help with the YOY function.

I have created a Calendar table for a continuous date. I have tried DateADD and SameperiodLastYear both to get YOY. 

YOY_Actual = CALCULATE(SUM(Com[Actual]),DATEADD('Calendar'[Date],-1,YEAR))
SamePeriodLastYear = CALCULATE(SUM(Com[Actual]),SAMEPERIODLASTYEAR('Calendar'[Date]))
The issue is, that I get the same value as the current year. I checked DATEADD('Calendar'[Date],-1,YEAR) function date. It shows the previous year's date. But when I run this function, it shows the current value instead of the previous year's value. Please help me.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous,

You can update the formula of measure [YOY_Actual] and [SamePeriodLastYea] as below, please find the details in the attachment.

YOY_Actual =
CALCULATE (
    SUM ( Com[Actual] ),
    DATEADD ( 'Calendar'[Date], -1, YEAR ),
    ALLSELECTED ( 'Com' )
)
SamePeriodLastYear =
CALCULATE (
SUM ( Com[Actual] ),
SAMEPERIODLASTYEAR ( 'Calendar'[Date] ),
ALLSELECTED ( 'Com' )
)

yingyinr_0-1657013364932.png

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi  @Anonymous,

You can update the formula of measure [YOY_Actual] and [SamePeriodLastYea] as below, please find the details in the attachment.

YOY_Actual =
CALCULATE (
    SUM ( Com[Actual] ),
    DATEADD ( 'Calendar'[Date], -1, YEAR ),
    ALLSELECTED ( 'Com' )
)
SamePeriodLastYear =
CALCULATE (
SUM ( Com[Actual] ),
SAMEPERIODLASTYEAR ( 'Calendar'[Date] ),
ALLSELECTED ( 'Com' )
)

yingyinr_0-1657013364932.png

Best Regards

amitchandak
Super User
Super User

@Anonymous , Both these should give you last year value

 

YOY_Actual = CALCULATE(SUM(Com[Actual]),DATEADD('Calendar'[Date],-1,YEAR))
SamePeriodLastYear = CALCULATE(SUM(Com[Actual]),SAMEPERIODLASTYEAR('Calendar'[Date]))

 

 

The calendar table should be marked date tbale

Slicer and visual should use the period from the calendar whenever needed

Single directional join

 

refer

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5bd4
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 :radacad sqlbi My Video Series 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

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.