There are a few different ways that you could structure this formula, but here’s one way to do it:
IF(
AND({# nights}>7,{Cabin Name}=299),1800,
IF(
AND({# nights}>7,{Cabin Name}=514),1850)
)
I’m actually not sure how to get the formula to spit out the value 0 — Airtable removes the number 0 from the formula if you try to add 0 into the formula. So this formula will result in a blank field instead of 0.
Perhaps someone else could chime in on how to get it to spit out the number 0!
There are a few different ways that you could structure this formula, but here’s one way to do it:
IF(
AND({# nights}>7,{Cabin Name}=299),1800,
IF(
AND({# nights}>7,{Cabin Name}=514),1850)
)
I’m actually not sure how to get the formula to spit out the value 0 — Airtable removes the number 0 from the formula if you try to add 0 into the formula. So this formula will result in a blank field instead of 0.
Perhaps someone else could chime in on how to get it to spit out the number 0!
Here’s an adjusted formula that will output 0 if the other conditions aren’t met:
IF(
AND(
{# Nights}>7,{Cabin Name}=299
),
1800,
IF(
AND(
{# Nights}>7,{Cabin Name}=514
),
1850,
0
)
)
You need to add 0 as the ELSE
part of the second conditional statement, and move the closing parenthesis for both statements after that.
Here’s an adjusted formula that will output 0 if the other conditions aren’t met:
IF(
AND(
{# Nights}>7,{Cabin Name}=299
),
1800,
IF(
AND(
{# Nights}>7,{Cabin Name}=514
),
1850,
0
)
)
You need to add 0 as the ELSE
part of the second conditional statement, and move the closing parenthesis for both statements after that.
Oh, thanks, @Jason! Haha, that’s what I was trying to do, but now I realize that I must have typed my 0 within the wrong set of parentheses! I really need to start using a text editor app to do my formulas, instead of typing them directly into the formula field!
Here are two other possible formulas with a slightly different approach.
These versions use a switch statement instead of nested IF
statements, so they are a little more maintainable if you have many more cabins, or if you want to change up the number of nights.
These formulas assume that {Cabin Name} is a single select or single line text field. If it is a number field, just remove the quotes.
Option with nested SWITCH
:
IF(Nights >= 7,
SWITCH({Cabin Name},
"299", 1800,
"514", 1850,
0
),
0
)
Option with nested IF
:
SWITCH({Cabin Name},
"299", IF(Nights >= 7, 1800, 0),
"514", IF(Nights >= 7, 1850, 0),
0
)
If you have the answer to your question, please mark one of the posts as the solution. Otherwise, could you please give a bit more details and a screen capture?
Here’s an adjusted formula that will output 0 if the other conditions aren’t met:
IF(
AND(
{# Nights}>7,{Cabin Name}=299
),
1800,
IF(
AND(
{# Nights}>7,{Cabin Name}=514
),
1850,
0
)
)
You need to add 0 as the ELSE
part of the second conditional statement, and move the closing parenthesis for both statements after that.
Thank you very much. This was perfect, although I am still trying to figure out just HOW it works!
Heather