Forum Discussion

sraj's avatar
sraj
Icon for Responsive Resident rankResponsive Resident
4 years ago
Solved

Last year vs this year

 

 

Hi there,
 
I have this function looking for 2021 and 2020, is there anyway I can use this and make it to look for Last Year Vs this year?  Instead of updating this every year?  Please advise.
 
 
CALCULATE(
[onsite %new],
HEA_DATE_Detail[Year] = 2021
)
-
CALCULATE(
[onsite %new],
HEA_DATE_Detail[Year] = 2020
)

2 Replies

  • bcdobbs's avatar
    bcdobbs
    Icon for Community Champion rankCommunity Champion

    YEAR ( TODAY () ) and YEAR ( TODAY () ) -1 could be direct replacements in the above.

  • aj1973's avatar
    aj1973
    Icon for Community Champion rankCommunity Champion

    Hi sraj 

    Use DATEADD  in the filter context of your formulas instead of HEA_DATE_Detail[Year] = 2021

    Iike 

    DATEADD(HEA_DATE_Detail[DATE],0, YEAR) for this year
    And
    DATEADD(HEA_DATE_Detail[DATE],-1, YEAR) for last year