Forum Discussion

RussellHansen's avatar
RussellHansen
Qrew Trainee
2 years ago

Formula Stops after first IF statement.

I have a Formula that has multiple IF statement, but after the formula processes the first IF statement, it will not continue to the other IF statements. I have tried a "," after every IF statement and "&" after every IF statement, but that has not working. The Formula is looking at the output of a Multi-select Text field. Here is an example of my Formula. 

If(Contains([Field1],"Value 1"), ToText("|Value 1:") & " " & [Field 2],
If(Contains([Field1],"Value 2"), ToText(" |Value 2:") & " " & [Field 3],
If(Contains([Field1],"Value 3"), ToText(" |Value 3:") & " " & [Field 4,
If(Contains([Field1],"Value 4"), ToText(" |Value 4") & " " & [Field 5))))

What's happening is that if Field 1 outputs "Value 1" and Value 4 then only the First IF statement will ToText and not the Fourth IF statement as well. 

The desired output should be "|Value 1 Field 2 |Value 4 Field 5"



------------------------------
Russell Hansen
------------------------------

2 Replies

  • MarkShnier__You's avatar
    MarkShnier__You
    Qrew #1 Challenger

    Try this

    List(" ",

    If(Contains([Field1],"Value 1"), ToText("|Value 1:") & " " & [Field 2]),
    If(Contains([Field1],"Value 2"), ToText("|Value 2:") & " " & [Field 3]),
    If(Contains([Field1],"Value 3"), ToText("|Value 3:") & " " & [Field 4]),
    If(Contains([Field1],"Value 4"), ToText("|Value 4") & " " & [Field 5))

    Note that you can simplify this syntax here

    ToText(" |Value 4")

    with just

    " |Value 4"

    The List function will separate any non empty results of the IF with, in my example, a space, but you can use any string in the Quotes as the separator. 



    ------------------------------
    Mark Shnier (Your Quickbase Coach)
    mark.shnier@gmail.com
    ------------------------------
    • RussellHansen's avatar
      RussellHansen
      Qrew Trainee

      Mark, you are the man! 

      I have learned something new today. Thank you for the help!



      ------------------------------
      Russell Hansen
      ------------------------------