I want to create a formula to select the SECOND-LARGEST value among five different categories. I’ve already created one to select the LARGEST value (called “Category 1), and then my thought was to exclude that category and return the max of the remaining four fields. With the help of Airtable’s AI, I got this formula:
IF(
{Category 1} = "Connections",
SWITCH(
MAX({Events}, {Programs}, {Support}, {Marketing}),
{Events}, "Events",
{Programs}, "Programs",
{Support}, "Support",
{Marketing}, "Marketing"
),
IF(
{Category 1} = "Events",
SWITCH(
MAX({Connections}, {Programs}, {Support}, {Marketing}),
{Connections}, "Connections",
{Programs}, "Programs",
{Support}, "Support",
{Marketing}, "Marketing"
),
IF(
{Category 1} = "Programs",
SWITCH(
MAX({Connections}, {Events}, {Support}, {Marketing}),
{Connections}, "Connections",
{Events}, "Events",
{Support}, "Support",
{Marketing}, "Marketing"
),
IF(
{Category 1} = "Support",
SWITCH(
MAX({Connections}, {Events}, {Programs}, {Marketing}),
{Connections}, "Connections",
{Events}, "Events",
{Programs}, "Programs",
{Marketing}, "Marketing"
),
IF(
{Category 1} = "Marketing",
SWITCH(
MAX({Connections}, {Events}, {Programs}, {Support}),
{Connections}, "Connections",
{Events}, "Events",
{Programs}, "Programs",
{Support}, "Support"
),
BLANK()
)))))Unfortunately, this returns the error “Sorry, there was a problem creating this field. Invalid formula. Please check your formula text.”
ChatGPT suggested the following edit:
SWITCH(
{Category 1},
"Connections",
SWITCH(
MAX({Events}, {Programs}, {Support}, {Marketing}),
{Events}, "Events",
{Programs}, "Programs",
{Support}, "Support",
{Marketing}, "Marketing"
),
"Events",
SWITCH(
MAX({Connections}, {Programs}, {Support}, {Marketing}),
{Connections}, "Connections",
{Programs}, "Programs",
{Support}, "Support",
{Marketing}, "Marketing"
),
"Programs",
SWITCH(
MAX({Connections}, {Events}, {Support}, {Marketing}),
{Connections}, "Connections",
{Events}, "Events",
{Support}, "Support",
{Marketing}, "Marketing"
),
"Support",
SWITCH(
MAX({Connections}, {Events}, {Programs}, {Marketing}),
{Connections}, "Connections",
{Events}, "Events",
{Programs}, "Programs",
{Marketing}, "Marketing"
),
"Marketing",
SWITCH(
MAX({Connections}, {Events}, {Programs}, {Support}),
{Connections}, "Connections",
{Events}, "Events",
{Programs}, "Programs",
{Support}, "Support"
),
BLANK()
)This too returns the error “Sorry, there was a problem creating this field. Invalid formula. Please check your formula text.”
I don’t believe either formula has syntax or field name errors. Any suggestions (other than switching to Python)?
EDIT TO ADD: Upon further research, I think the first formula above doesn’t work because there are too many nested IF statements. My workaround solution is to create a separate formula field for each possible value in Category 1, then concatenate the five fields into a sixth field. It’s VERY inelegant but works. Would still love to hear if anyone can think of something better!

