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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
unclejemima
Post Patron
Post Patron

Yesterday last year DAX formula

For today I'm using 

 

Today= DATE(YEAR(NOW()),MONTH(NOW()), DAY(NOW())

 

How would I display Today last year?  I was thinking

TodayPrevYear = DATE(YEAR(NOW()-1),MONTH(NOW()), DAY(NOW())

 

But I get an error.


Can someone show me the correct formula to use for Today Last year?

3 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

Perhaps something like: 

 

Measure = DATE(YEAR(NOW())-1,MONTH(NOW()), DAY(NOW()-1))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Sean
Community Champion
Community Champion

@unclejemima

You have to subtract 1 from the result of the YEAR function not inside the argument!

If you do YEAR ( NOW()-1 ) as you you've done you are basically asking for the function to return the YEAR of NOW()-1

which would be yesterday this year - thats why you have to get the year first and then subtract 1

TodayPrevYear = DATE ( YEAR ( NOW () ) - 1, MONTH ( NOW () ), DAY ( NOW () ) )

And same if you want yesterday previous year

Obviously for Day it won't matter if you subtract 1 inside or not

YesterdayPrevYear = DATE ( YEAR ( NOW () ) - 1, MONTH ( NOW () ), DAY ( NOW () ) - 1 )

 Hope this helps! Smiley Happy

View solution in original post

Vvelarde
Community Champion
Community Champion

@unclejemima

 

Hi, You can also obtain:

 

Today-inPreviousYear = EDATE(TODAY(),-12)

Yesterday-inPreviousYear = EDATE(TODAY(),-12)-1




Lima - Peru

View solution in original post

5 REPLIES 5
Sean
Community Champion
Community Champion

@unclejemima

You have to subtract 1 from the result of the YEAR function not inside the argument!

If you do YEAR ( NOW()-1 ) as you you've done you are basically asking for the function to return the YEAR of NOW()-1

which would be yesterday this year - thats why you have to get the year first and then subtract 1

TodayPrevYear = DATE ( YEAR ( NOW () ) - 1, MONTH ( NOW () ), DAY ( NOW () ) )

And same if you want yesterday previous year

Obviously for Day it won't matter if you subtract 1 inside or not

YesterdayPrevYear = DATE ( YEAR ( NOW () ) - 1, MONTH ( NOW () ), DAY ( NOW () ) - 1 )

 Hope this helps! Smiley Happy

Vvelarde
Community Champion
Community Champion

@unclejemima

 

Hi, You can also obtain:

 

Today-inPreviousYear = EDATE(TODAY(),-12)

Yesterday-inPreviousYear = EDATE(TODAY(),-12)-1




Lima - Peru
Anonymous
Not applicable

How would you today in previous year for FiscalDayOfYear ?

Greg_Deckler
Super User
Super User

Perhaps something like: 

 

Measure = DATE(YEAR(NOW())-1,MONTH(NOW()), DAY(NOW()-1))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thank you Greg, so helpful.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.