cancel
Showing results for
Did you mean:
Member

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

Accepted Solutions
Super User

## Re: Yesterday last year DAX formula

Perhaps something like:

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

### I have book! Learn Power BI from Packt

Proud to be a Datanaut!

Highlighted
Super Contributor

## Re: Yesterday last year DAX formula

@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!

Super Contributor

## Re: Yesterday last year DAX formula

@unclejemima

Hi, You can also obtain:

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

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

Lima - Peru

Proud to be a Datanaut!

3 REPLIES 3
Super User

## Re: Yesterday last year DAX formula

Perhaps something like:

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

### I have book! Learn Power BI from Packt

Proud to be a Datanaut!

Highlighted
Super Contributor

## Re: Yesterday last year DAX formula

@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!

Super Contributor

## Re: Yesterday last year DAX formula

@unclejemima

Hi, You can also obtain:

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

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

Lima - Peru

Proud to be a Datanaut!

Announcements

#### Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

#### Community News & Announcements

Get your latest community news and announcements.

#### Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

#### Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Top Kudoed Authors
Users Online
Currently online: 123 members 1,497 guests
Recent signins: