Simple If function

I need a simple formula for working out a suburb and it puts out a selected output.

eg: if the suburb gorokan or toukley is in the field, the formula puts in KPM1. IF the suburb is hamlyn terrace it puts in KPM2 etc etc This will apply to 5 different outputs ( KPM1 KPM2 KPM 3 KPM4 LM1) based on the suburb.

IF({Suburb}=“gorokan”, “KPM1”)

This formula works great for the single suburb but I cant get it to output KPM1 if I put multiple suburbs in there
I know it will be nested IF formulas but I just cant get this first one to work as expected.
It will be simple im sure! lol

It might be easier to use a SWITCH() statement, since you are checking the same field, namely {Suburb}, each time.


SWITCH(
   {Suburb},
   "gorokan", "KPM1",
   "hamlyn terrace", "KPM2",
   ...
)

yep, that works but is there a way so I dont have to do individual suburbs? eg:

“gorokan, toukley, etc, etc”, “KPM1”
“hamlayn terrace, kanwal, etc etc” “KPM2”

I would prefer to group the suburbs into one part of the formula rather than 1 per suburb as I have about 30 to do. lol

Nope.
You could group them together in a repeated IF(OR()) structure, but you’d likely end up writing more characters, only to have a far less readable formula.

I’d suggest biting the bullet and writing out the explicit SWITCH() function. Perhaps a good Programming text editor would come in handy here…

Thats what I thought! lol

Already writing it out, not the most elegant but at least it will work!

Thanks for the help!

1 Like

If you think 30 lines in a SWITCH() function is bad, you should take a look at this formula I had to write for a client…

haha… cut and paste is your friend there!

Im only new to airtable and functions, formula’s / excel in general and can do the basics but I get lost in all the (((((( ) ()))))))'s

I refer you to a programming text editor again.
Auto-indentation and auto-closing of parentheses and brackets will make your life much easier.

I will certainly look into it! ( your link above where you suggested it doesnt work if you were recommending one.)

Fixed it (20 characters)

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.