# If and Then Formula help

#1

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)

#2
``````IF(
{Field} = 'A',
{Field}*15,
IF(
{Field}='B',
{Field}*20
)
)
``````

#3

2 notes

• If you only can have A or B, you don’t need the second IF
• I think you can do `Field * IF(Field = 'A', A, B)`
• Also, if you’re multiplying a number you must not use `'` around the values.

And of course check the docs: https://support.airtable.com/hc/en-us/articles/203255215-Formula-field-reference#logical

#4

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.

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.’~ )