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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
pabeader
Post Patron
Post Patron

how to correctly calculate yesterday

I am trying to calculate yesterday so I can correctly work with our weird shift schedule.  Here is what I have so far.

 

DateOfInterest =
IF (
    HOUR ( NOW () ) >= 0
        && HOUR ( NOW () ) <= 6,
    DAY ( TODAY () ) - 1,
    DAY ( TODAY () )
)

 

I'm concerned that this will not correctly handle things at the end/start of a month, but I just can't think of how to correct for that.

 

1 ACCEPTED SOLUTION
ValtteriN
Super User
Super User

Hi,

If you are just interested in the previous datenumber you can simply include the -1 within the DAY funtion.
For example this dax day(1/12/2021-1) 
will return 30.

I hope this helps to solve your issue and if it does consider accepting this as a solution!





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

Proud to be a Super User!




View solution in original post

2 REPLIES 2
ValtteriN
Super User
Super User

Hi,

If you are just interested in the previous datenumber you can simply include the -1 within the DAY funtion.
For example this dax day(1/12/2021-1) 
will return 30.

I hope this helps to solve your issue and if it does consider accepting this as a solution!





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

Proud to be a Super User!




Thanks for that!  I feel kinda stupid for not even thinking to try that.  Works great!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.