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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
v-yiruan-msft
Community Support
Community Support

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

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

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

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors