Skip to main content
Solved

Nested 3 IF() statements with 3 AND()

  • Feb 22, 2020 11:53 AM UTC
  • 3 replies
  • 87 views

Forum|alt.badge.img+2

What is wrong with my nested if? It says that that It’s invalid

IF(
  AND(
    {5dayswithnochange},
    {issueStatus🟢or🔴or🟠}=🟢
  ), 
  "Stable ⚖", 
  IF(
    AND(
      {5dayswithnochange}, 
      {issueStatus🟢or🔴or🟠}=🟠
    ), 
    "Stuck 🆘", 
    IF(
      AND(
        {5dayswithnochange},
        {issueStatus🟢or🔴or🟠}=🔴
      ), 
      "Broken 🔥", 
      "Too soon to tell ❔"
    )
  )
)

Best answer by Julien_Reszka

nevermind, I forgot to add the quotes “” around the emojis :green_circle: in the equality evaluations
Correct code

IF(
  AND(
    {5dayswithnochange},
    {issueStatus🟢or🔴or🟠}="🟢"
  ), 
  "Stable ⚖", 
  IF(
    AND(
      {5dayswithnochange}, 
      {issueStatus🟢or🔴or🟠}="🟠"
    ), 
    "Stuck 🆘", 
    IF(
      AND(
        {5dayswithnochange},
        {issueStatus🟢or🔴or🟠}="🔴"
      ), 
      "Broken 🔥", 
      "Too soon to tell ❔"
    )
  )
)
View original
This topic has been closed for replies.

3 replies

Forum|alt.badge.img+2
  • Author
  • New Participant
  • Answer
  • Feb 22, 2020 12:00 PM UTC

nevermind, I forgot to add the quotes “” around the emojis :green_circle: in the equality evaluations
Correct code

IF(
  AND(
    {5dayswithnochange},
    {issueStatus🟢or🔴or🟠}="🟢"
  ), 
  "Stable ⚖", 
  IF(
    AND(
      {5dayswithnochange}, 
      {issueStatus🟢or🔴or🟠}="🟠"
    ), 
    "Stuck 🆘", 
    IF(
      AND(
        {5dayswithnochange},
        {issueStatus🟢or🔴or🟠}="🔴"
      ), 
      "Broken 🔥", 
      "Too soon to tell ❔"
    )
  )
)

kuovonne
Forum|alt.badge.img+29
  • Brainy
  • Feb 23, 2020 1:37 AM UTC

Glad you were able to fix your issue yourself!

However, I happened to see your formula and thought you might be interested in a slightly simpler version. This version has less nesting and eliminates the need for the AND functions. It also uses the SWITCH function, which is really useful for when dealing with multiple possible values for a single field.

IF ({5dayswithnochange},
    SWITCH({issueStatus🟢or🔴or🟠},
      "🟢", "Stable ⚖", 
      "🟠", "Stuck 🆘", 
      "🔴", "Broken 🔥"
    ),
    "Too soon to tell ❔"
)

Forum|alt.badge.img+2
  • Author
  • New Participant
  • Feb 23, 2020 7:59 AM UTC

Glad you were able to fix your issue yourself!

However, I happened to see your formula and thought you might be interested in a slightly simpler version. This version has less nesting and eliminates the need for the AND functions. It also uses the SWITCH function, which is really useful for when dealing with multiple possible values for a single field.

IF ({5dayswithnochange},
    SWITCH({issueStatus🟢or🔴or🟠},
      "🟢", "Stable ⚖", 
      "🟠", "Stuck 🆘", 
      "🔴", "Broken 🔥"
    ),
    "Too soon to tell ❔"
)

Tank you! simpler syntax indeed.