cancel
Showing results for
Did you mean:

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Super User

Perhaps something like:

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

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
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!

Community Champion

@unclejemima

Hi, You can also obtain:

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

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

Lima - Peru
5 REPLIES 5
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!

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 ?

Super User

Perhaps something like:

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

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
The Definitive Guide to Power Query (M)

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

Announcements

#### 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

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors