Aug 12, 2022 11:47 AM
Hello!
I am trying to make a formula based on an IF statement.
IF one cell = something, then perform this formula. For example,
IF(
{Frequency},
‘Annual’,({Cost/12}))
I would like to have multiple “IF” statements & formulas. Is this possible?
Solved! Go to Solution.
Aug 13, 2022 06:29 AM
SWITCH( {Frequency},
"Weekly", {Cost} * 4.3,
"Monthly", {Cost},
"Annual", {Cost} / 12
)
In general, put field names in curly braces {}
and put literal text strings in straight quotes " "
.
Aug 12, 2022 01:16 PM
Hi @Lindsay_Kirsch,
You are pretty close you your IF statement. The format is like this:
IF(something that can be true, if true do this, is not true do this)
Notice there are 3 sections separated by a comma.
But…
SWITCH() would likely be better than nesting IF().
the format for that would be
SWITCH(
{Field Name},
option, result,
option, result,
'default')
Aug 12, 2022 04:14 PM
I am still having trouble - Image 2022-08-12 at 7.13.35 PM
SWITCH(
Frequency,
Annual,=SUM(Cost/12),
'default')
Aug 12, 2022 04:57 PM
Hey @Lindsay_Kirsch!
Unlike a spreadsheet application, Airtable’s formula syntax does not use =
characters in front of functions.
So you’d just remove the character from the SUM function and it should work.
Quick Edit:
Noticed this just now.
This function will probably throw an error at you.
If you’re trying to just divide the {Cost} by 12, then you can remove it from the SUM function and just put in: ({Cost} / 12)
, and it will do so.
It should probably look something like this:
SWITCH(
{Frequency},
{Annual}, ({Cost} / 12),
'Default'
)
Aug 12, 2022 05:16 PM
Still not working :frowning: Image 2022-08-12 at 8.16.43 PM
Aug 13, 2022 06:08 AM
I would like to calculate the total monthly cost based on the variables in Frequency.
So if Frequency = Weekly then it would be Cost*4.3
If Frequency = Annual then it would be Cost/12
Aug 13, 2022 06:29 AM
SWITCH( {Frequency},
"Weekly", {Cost} * 4.3,
"Monthly", {Cost},
"Annual", {Cost} / 12
)
In general, put field names in curly braces {}
and put literal text strings in straight quotes " "
.
Aug 13, 2022 07:00 AM
This worked! Thank you so much!