cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kartiklal03
Helper I
Helper I

DAX for Calculated Column for Yesterday and Same Day Last Year

Hi All,

 

I need a little help in creating a calculated column for Yesterday and the Same Day Last Year based of a date column in my orders table. 

 

For example, this column should return true if the date in my date column is either 5/26/2021 or 5/26/2020 (based on the current date) and FALSE otherwise. 

 

Thanks in advance!

1 ACCEPTED SOLUTION
selimovd
Community Champion
Community Champion

Hey @Kartiklal03 ,

 

try the following approach:

 

Yesterday or LY =
IF(
    myTable[date] = TODAY()-1 || myTable[date] = DATE ( YEAR ( TODAY() -1 ) - 1, MONTH ( TODAY() -1 ), DAY (  TODAY() -1 ) ),
    TRUE,
    FALSE
)

 

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

2 REPLIES 2
selimovd
Community Champion
Community Champion

Hey @Kartiklal03 ,

 

try the following approach:

 

Yesterday or LY =
IF(
    myTable[date] = TODAY()-1 || myTable[date] = DATE ( YEAR ( TODAY() -1 ) - 1, MONTH ( TODAY() -1 ), DAY (  TODAY() -1 ) ),
    TRUE,
    FALSE
)

 

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

@selimovd , 

 

Thank you. That's perfect and exactly what I was looking for. 

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.