Apr 09, 2020 04:43 AM
Hello Airtablers!
For my CRM I’m trying to automate the ranking of my prospects from “ :fire: Flaming hot” to " :skull: Dead".
I tried using a SWITCH formula but got in difficulties, so I reverted to IF and DATETIME_DIFF.
I want to switch between the 6 values below and though I managed an IF statement with just 2 values, when I try 6 (and DATETIME_DIFF) I get no-where (I even checked for curly brackets, straight quote marks and the number or parentheses)!
Can you help?
I tried the following:
IF({Last Contact}=TODAY(),"🔥 Hot!",
IF((DATETIME_DIFF{Last Contact},TODAY(),'days')>3,"🌡 Warm",
IF((DATETIME_DIFF{Last Contact},TODAY(),'days')>7,"😎 Chilled",
IF((DATETIME_DIFF{Last Contact},TODAY(),'days')>21,"🚰 Tepid",
IF((DATETIME_DIFF{Last Contact},TODAY(),'days')<90,"🥶 Cold",
"💀 Dead!")
)
)
)
)
Thanks in advance!
Solved! Go to Solution.
Apr 09, 2020 07:45 AM
Hi there!
Looks like you’ve got some parentheses misplaced. For each time you’ve written…
IF((DATETIME_DIFF{Last Contact},TODAY()...
There is an extra parentheses after “IF”, and you’re missing one before “{Last Contact}”:
IF(DATETIME_DIFF({Last Contact},TODAY()...
The entire formula should look like…
IF({Last Contact}=TODAY(),"🔥 Hot!",
IF(DATETIME_DIFF({Last Contact},TODAY(),'days')>3,"🌡 Warm",
IF(DATETIME_DIFF({Last Contact},TODAY(),'days')>7,"😎 Chilled",
IF(DATETIME_DIFF({Last Contact},TODAY(),'days')>21,"🚰 Tepid",
IF(DATETIME_DIFF({Last Contact},TODAY(),'days')<90,"🥶 Cold",
"💀 Dead!")
)
)
)
)
Hope that helps!
Apr 09, 2020 07:45 AM
Hi there!
Looks like you’ve got some parentheses misplaced. For each time you’ve written…
IF((DATETIME_DIFF{Last Contact},TODAY()...
There is an extra parentheses after “IF”, and you’re missing one before “{Last Contact}”:
IF(DATETIME_DIFF({Last Contact},TODAY()...
The entire formula should look like…
IF({Last Contact}=TODAY(),"🔥 Hot!",
IF(DATETIME_DIFF({Last Contact},TODAY(),'days')>3,"🌡 Warm",
IF(DATETIME_DIFF({Last Contact},TODAY(),'days')>7,"😎 Chilled",
IF(DATETIME_DIFF({Last Contact},TODAY(),'days')>21,"🚰 Tepid",
IF(DATETIME_DIFF({Last Contact},TODAY(),'days')<90,"🥶 Cold",
"💀 Dead!")
)
)
)
)
Hope that helps!
Apr 09, 2020 08:05 AM
It also looks like you are using greater than signs instead of less than signs.
Most of your rankings aren’t reached because the formula stops evaluating when it finds the diff greater than 3.
Try using all less than signs and a final “else” condition.
Apr 09, 2020 09:53 AM
Wow, plenty of simple errors I hadn’t even noticed!
Thank you, will give it a go and report back
Apr 09, 2020 10:06 AM
My Google fu isn’t helping me find a cheatsheet for ‘else’ - what does it look like?
Apr 09, 2020 10:08 AM
You’re actually already using the else condition. It’s the third parameter in the IF
function. You can find the syntax in the formula field reference.
Apr 09, 2020 10:09 AM
Do you mean the last bit - return skull if none of the above?
Apr 09, 2020 10:13 AM
Yes, the skull is the final else parameter.
Technically, all of your nested if statements are also “else” conditions.
That is why I personally like to format nested if
statements the following way:
IF(condition1,
result1,
IF(condition2,
result2,
IF(condition3,
result3,
result4
)
)
)
Apr 09, 2020 10:16 AM
@kuovonne - I do that by inserting the line by two spaces, right?
Apr 09, 2020 10:36 AM
Oh dear, oh dear - now everything (even the really old contacts) are either ‘hot’ or ‘warm’ - no cool, tepid or zombies.
Should I put the list in order from largest to smallest? Does that help?