Forum Discussion

AnetaK's avatar
AnetaK
Icon for Helper V rankHelper V
8 years ago
Solved

IF on date - Expressions that yield variant data-type...

Hello,

 

I have four status dates and want to show on the report always the latest status with the possibility to change to other dates.

So I want to have "Last status" and the other dates.

Something like this: Column2 = IF('Status date'[Status date]=MAX('Status date'[Status date]);"Last status";'Status date'[Status date]).

But I get an error.

However it works for Column1 = IF('Status date'[Status date]=MAX('Status date'[Status date]);1;0)

 

Could anybody, please, help me with it?

 

 

  • Ha! I've found the solution! :)

     

    Status date = If('Status date'[Status date_date]=maX('Status date'[Status date_date]);"Last status";format('Status date'[Status date_date];"YYYY-MM-DD"))

6 Replies

  • BeemsC's avatar
    BeemsC
    Icon for Resolver III rankResolver III

    Basically what that error is saying, is that you are trying to use a string, where an integer was expected.
    So you are trying to write something, where a numeric value is expected. That's why 1 and 0 are working.

    You either need to make both integer, or both strings.
    So your code fixed would look something like this :

    Column2 = IF('Status date'[Status date]=MAX('Status date'[Status date]);"Last status";"Not last status")

    • AnetaK's avatar
      AnetaK
      Icon for Helper V rankHelper V

      But I need a date.

      I want to have a slicer with dates and "Last status".

       

       

       

      • BeemsC's avatar
        BeemsC
        Icon for Resolver III rankResolver III

        You can't have the dates and the 'Last Date' together in one column/slicer, (for as far as i know)