Jul 16, 2018 06:09 AM
Good morning
I want to create a formula based on field
For example
If this field is = to A then do this ( Field X *15 ) … if the field is = to B then do this ( Field X *20)
Jul 16, 2018 11:53 AM
IF(
{Field} = 'A',
{Field}*15,
IF(
{Field}='B',
{Field}*20
)
)
Jul 16, 2018 02:08 PM
2 notes :grinning_face_with_smiling_eyes:
Field * IF(Field = 'A', A, B)
'
around the values.And of course check the docs: https://support.airtable.com/hc/en-us/articles/203255215-Formula-field-reference#logical
Jul 16, 2018 04:29 PM
Depending on what the ‘else’ section of the formula is, though, writing it as an A-or-B choice can mean the field shows as '#ERROR'
or 'NaN'
until something is entered in the matched field — which can worry some users and make executive presentations very uncomfortable. :winking_face:
I’ve been trying to force myself into the habit of wrapping most formulas with an IF()
statement whose job is simply to prevent the formula from being executed until there is actual data entry to evaluate (comments for illustrative purposes only; can’t be included in actual formula):
IF(
{Field}, ; means '{Field} is not empty'
[The original formula] ; execute the formula
) ; otherwise, do nothing
And, of course, if the field might match 'A'
or it might match 'B'
or it might be empty or match a value other than 'A'
or 'B'
, the A-or-B solution doesn’t work. (I know you know that, but filling in some blanks for the user who finds this thread a year from now while searching ‘Ask the community.’~ :slightly_smiling_face: )