cancel
Showing results for
Did you mean:

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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