Upcoming database upgrades. to improve our reliability at 03:30 UTC on Feb. 25 / 7:30pm PT on Feb. 24. Some users may briefly experience slow load times or error messages. Learn more here

# Simple If function

Topic Labels: Formulas
Solved
1042 9
cancel
Showing results for
Did you mean:
6 - Interface Innovator

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

1 Solution

Accepted Solutions
14 - Jupiter

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

### Formula field reference

For an overview of formula fields, please refer to the Guide to Formula, Lookup, Count, and Rollup fields. Formulas may involve functions, numeric operations, logical operations, and text operation...

SWITCH(
{Suburb},
"gorokan", "KPM1",
"hamlyn terrace", "KPM2",
...
)
9 Replies 9
14 - Jupiter

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

### Formula field reference

For an overview of formula fields, please refer to the Guide to Formula, Lookup, Count, and Rollup fields. Formulas may involve functions, numeric operations, logical operations, and text operation...

SWITCH(
{Suburb},
"gorokan", "KPM1",
"hamlyn terrace", "KPM2",
...
)
6 - Interface Innovator

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

14 - Jupiter

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…

6 - Interface Innovator

Thats what I thought! lol

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

Thanks for the help!

14 - Jupiter

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…

6 - Interface Innovator

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

14 - Jupiter

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

6 - Interface Innovator

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

14 - Jupiter

Fixed it (20 characters)