Help

SWITCH() and Multiple Select Fields

Topic Labels: Formulas
7264 5
cancel
Showing results for 
Search instead for 
Did you mean: 
Matt_Caruso
6 - Interface Innovator
6 - Interface Innovator

Can a SWITCH() formula be used to output different criteria for different options and/or combinations of a multiple select field?

Essentially, I want to say: “If multiple select field contains Option 1, return Result A. If it also contains Option 2, return Result A, Result B.”

So far, when I’ve made a SWITCH() function, it will only return if a multiple select field is one thing or another but won’t return if it’s both things.

How could this be built without a zillion characters of different scenarios written out in the formula?

5 Replies 5

Hi @Matt_Caruso - as you say a SWITCH() formula is going to get messy pretty quickly. Even with two options:

Screenshot 2019-05-20 at 07.21.51.png

And this formula:

SWITCH(
{Multi-select}, 
'Option 1', 'Result 1', 
'Option 2', 'Result 2', 
'Option 1, Option 2', 'Result 1, Result 2'
)

I’m still not there as I need to code for the “Option 2, Option 1” choice. Get this to 3, 4, 5 options and you’ve got a big formula on your hands. An easier option is to make the multi-select a link from a reference table:

Screenshot 2019-05-20 at 07.24.38.png

Now, instead of the multi-select, you link to your option, then do a lookup to get the result:

Screenshot 2019-05-20 at 07.25.04.png

This will be much easier to handle with multiple options and combinations of options selected.

JB

AlliAlosa
10 - Mercury
10 - Mercury

Not sure if this would work, but could you make use of the SUBSTITUTE() function? If, for example, “Option 1” always equals “Result A”, and so on, you could write something like…

SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE({Options}, "Option", "Result"), "1", "A"), "2", "B"), "3", "C"), "4", "D")

Of course, this would end up being a long formula as well depending on how many numbers/letters you need to convert. And depending on your use case, this might not work at all. Just thought I’d throw it out there!

Both solutions provided are excellent IMO. My gut says that for small scenarios, the SUBSTITUTE option might be preferable, whereas I’d lean toward the link choice for larger setups.

Matt_Caruso
6 - Interface Innovator
6 - Interface Innovator

Thanks so much for the input. I think I’ve accepted this is too complex to warrant the cost/benefit.

What about comparing two multiple select fields and then creating a third field that just says if they match? The problem I’m running into is that Airtable seems to care what the order of the multiple select options are:

02%20PM

When working with the data from multiple-select fields (and several others like rollups, links, etc.), you’re working with arrays. While Airtable does have some array functions, it doesn’t have the ability to compare arrays at this time, nor does it have any way of iterating through an array and performing operations/comparisons on each item (to work around the lack of a direct array-comparison function).

The linking method proposed by @JonathanBowen isn’t very different from setting up and using a multiple-select field. Not sure what part of it is too complex.