Forum Discussion

sdas028's avatar
sdas028
Helper I
7 years ago
Solved

IF Statement DAX Month

Hi,   I have a date field in a large table of data, I want to have an IF statement in an added column where it says Yes if the month (or date) is equal to or less than todays date and No if it isnt...
  • v-frfei-msft's avatar
    7 years ago

    Hi sdas028 ,

     

    We can create a calculated column to make sure the reuslt is correct if there are different years in your fact table.

     

    YTD = var monthyear = YEAR(Table1[Posting date])*100+MONTH(Table1[Posting date])
    var _today = YEAR(TODAY())*100+MONTH(TODAY())
    return
    IF(monthyear<=_today,"Yes","No")

    For more details, please check the pbix as attached.

     

    Regards,
    Frank