The Formula Must Be of Type Date Error with Ifelse formula

I am trying to return a specific date based on the team name field. If the team name is ABC, pull the date from a related opportunities field, othewise make the date equal to the close date plus a given lead time. Here is the formula I am currently working with but I keep getting an error that says "The formula must be of type date":

ifElse(equal($team_name_c,"ABC"),related($opportunities,"revenue_start_date_c"),addDays($date_closed,multiply($lead_time_c,7)))

  • Hi Adam Ritchie,

    If I understand correctly, the output of the formula needs to be of type Date because this calculation is in a Date type field.

    Right now, this formula has two outputs:

    related($opportunities,"revenue_start_date_c") -- this outputs a string

    AND

    addDays($date_closed,multiply($lead_time_c,7)) -- this outputs a date

     

    The error is occurring because the first output is a string, not a date. related() outputs string regardless what datatype the related field is. date() converts string to date type. So, try the following variation of your formula:

    ifElse(equal($team_name_c,"ABC"),date(related($opportunities,"revenue_start_date_c")),addDays($date_closed,multiply($lead_time_c,7)))

    I hope this helps!