cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
unclejemima Member
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
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


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

View solution in original post

Sean Super Contributor
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! Smiley Happy

View solution in original post

Vvelarde Super Contributor
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
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!




View solution in original post

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


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

View solution in original post

Sean Super Contributor
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! Smiley Happy

View solution in original post

Vvelarde Super Contributor
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
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!




View solution in original post

vinS Frequent Visitor
Frequent Visitor

Re: Yesterday last year DAX formula

How would you today in previous year for FiscalDayOfYear ?

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)