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
sraj
Responsive Resident
Responsive Resident

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 ACCEPTED SOLUTIONS
bcdobbs
Super User
Super User

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



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

aj1973
Community Champion
Community 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

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

View solution in original post

2 REPLIES 2
aj1973
Community Champion
Community 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

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

bcdobbs
Super User
Super User

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



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.