Forum Discussion

sarah8991's avatar
sarah8991
Frequent Visitor
4 years ago
Solved

Labelling Expired, Soon to Expire and Valid from End Date column

Hi,

 

I just started learning DAX- not sure if this should be done in DAX or Power Query. But what I'm trying to do is have a column that is automated to output "Expired", "Soon to Expire" and "Valid" depending on the "End Date" column. 

 

The "End Date" column feeds from our internal server. The output labelled "Soon to Expire" when the "End Date" is within 3 months from today.

 

 

Please advise how to get this.

 

Thanks!

 

  • Hi sarah8991 , Please check if the datatype of End Date column is a String or Date. If it is String then convert it into Date.
    Also, Try this:
    Result = if(day([enddate]) > Today(), "Expired", if(day([end date])+90 < Today(),"Valid", "Soon to expire"))

     

    sarah8991 -> hit the thumbs up & mark it as a solution if it helps you. Thanks.

5 Replies

  • truptis's avatar
    truptis
    Icon for Community Champion rankCommunity Champion

    Hi sarah8991 , Please check if the datatype of End Date column is a String or Date. If it is String then convert it into Date.
    Also, Try this:
    Result = if(day([enddate]) > Today(), "Expired", if(day([end date])+90 < Today(),"Valid", "Soon to expire"))

     

    sarah8991 -> hit the thumbs up & mark it as a solution if it helps you. Thanks.

    • sarah8991's avatar
      sarah8991
      Frequent Visitor

      Hi,

       

      Thank you! I changed it to Date and tried your suggestion, but now it can't seem to locate the "End Date" colum:

       

      Do you know why this is happening? 

       

      Thanks!

      • truptis's avatar
        truptis
        Icon for Community Champion rankCommunity Champion

        Hi sarah8991 ,

        Try this:

        Result = if(day('tablename'[enddate]) > Today(), "Expired", if(day('tablename'[end date])+90 < Today(),"Valid", "Soon to expire"))