Forum Discussion

vincenardo's avatar
vincenardo
Icon for Helper I rankHelper I
4 years ago
Solved

Compare Month and Year between two date fields

I have a table that has two dates for each record (TransDate & COCDate), I want to create a calculated column that will compare the Month and Year of 'TransDate' to the 'COCDate' and return BEFORE, I...
  • Anonymous's avatar
    Anonymous
    4 years ago

    vincenardo please try a Calculated Column with this DAX formula:

    DateStatus = 
        SWITCH(TRUE(),
            DATEDIFF([TransDate], [COCDate], MONTH) = 0, "IN",
            DATEDIFF([TransDate], [COCDate], MONTH) < 0, "BEFORE",
            DATEDIFF([TransDate], [COCDate], MONTH) > 0, "AFTER"
        )