cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Post Patron

## IS Last 2 Years True/False DAX

Can someone help me turn this formula I have for last 2 days into last 2 years True/False answer?

IsTwoDaysAgo = if('Calendar'[DateTime12am]=TODAY()-2,"True","False")

Let me know!
1 ACCEPTED SOLUTION
Super User

@unclejemima , IsTwoDaysAgo  is correct. if you need two years date , try like

IsTwoDaysAgo = if('Calendar'[DateTime12am]>=date(year(TODAY())-2,1,1) && [DateTime12am] <=today(),"True","False")

IsTwoDaysAgo = if('Calendar'[DateTime12am]>=date(year(TODAY())-2,month(TODAY()),day(TODAY())) && [DateTime12am] <=today(),"True","False")

3 REPLIES 3
Super User

@unclejemima , IsTwoDaysAgo  is correct. if you need two years date , try like

IsTwoDaysAgo = if('Calendar'[DateTime12am]>=date(year(TODAY())-2,1,1) && [DateTime12am] <=today(),"True","False")

IsTwoDaysAgo = if('Calendar'[DateTime12am]>=date(year(TODAY())-2,month(TODAY()),day(TODAY())) && [DateTime12am] <=today(),"True","False")

Post Patron

Thank you!!

Do both give the same result or why the different options?

I used this...

IsTwoYearsAgo = if('Calendar'[DateTime12am]>=date(year(TODAY())-2,month(TODAY()),day(TODAY())) && [DateTime12am] <=today(),"True","False")

Super User

Hi,

Try this calculated column formula

='Calendar'[DateTime12am]>=edate(today(),-24)

Hope this helps.

Regards,
Ashish Mathur
http://www.ashishmathur.com

Announcements

#### Power BI Monthly Update - July 2024

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

#### Fabric Community Update - July 2024

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

Top Solution Authors
Top Kudoed Authors