Forum Discussion

unclejemima's avatar
unclejemima
Icon for Post Patron rankPost Patron
5 years ago
Solved

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!
  • 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

  • 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")

    • unclejemima's avatar
      unclejemima
      Icon for Post Patron rankPost 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")

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Icon for Super User rankSuper User

        Hi,

        Try this calculated column formula

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

        Hope this helps.