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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Kolumam
Post Prodigy
Post Prodigy

Yesterday formula using datetime datatype in DAX

Hi All,

 

I need to compute yesterday with all the DateTime values but when I use the below-calculated column it returns just one value. I need all the date time values from yesterday.

Yesterday = IF('DATE'[Date] = (DATE(YEAR(NOW()), MONTH(NOW()), DAY(NOW()-1))), 1 , 0)

Please help.

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi, @Kolumam 

For the data type is datetime, so try this formula:

New Yesterday = IF(DATE(YEAR('DATE'[Date]),  MONTH('Date'[Date]), DAY('Date'[Date]))= (DATE(YEAR(NOW()), MONTH(NOW()), DAY(NOW()-1))), 1 , 0)

Result:

2.JPG

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-lili6-msft
Community Support
Community Support

hi, @Kolumam 

For the data type is datetime, so try this formula:

New Yesterday = IF(DATE(YEAR('DATE'[Date]),  MONTH('Date'[Date]), DAY('Date'[Date]))= (DATE(YEAR(NOW()), MONTH(NOW()), DAY(NOW()-1))), 1 , 0)

Result:

2.JPG

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @Kolumam ,

This is a way to do what you want, but as @MattAllington said it might not be the best approach to your problem :

Yesterday = IF(DATEADD('DATE'[Date],1,DAY)=TODAY(),1,0)

Regards,

Etienne

MattAllington
Community Champion
Community Champion

What are you going to do with this column after you create it?  It is unlikely that this is the best approach. What do you actually want to achieve?  



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.