This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Airtable Community
- Discussions
- Ask A Question
- Formulas
- Switch with nested if formula

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Printer Friendly Page

Topic Labels:
Formulas

Solved

Jump to Solution

0
554
4

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Jul 09, 2021 11:10 PM

Hi all! I’m looking for a solution in a switch formula, with nested if functions.

I want to calculate a percentage & addition based fee that changes based on the category input. Also with possible caveats on how that fee is calculated based on the price of the item. I’m hoping this is possible.

Example:

If Category=A, multiply by 12%

If Category=B, multiply by 9%, then add .50

If Category=C, AND the price is <$15, ADD $2, OR if Category=C, AND the price is >$14.99, multiply by 20%

Right now I have a separate table linked to include all this info, but I would love to set up a formula to calculate all of this within the main table. Thanks for the help!

Solved! Go to Solution.

1 Solution

Accepted Solutions

Solved
See Solution in Thread

Jul 10, 2021 12:30 AM

Assuming I understood your question, the simplest possible formula is:

```
SWITCH(
{Category},
"A", {Price} * .12,
"B", ({Price} * .09) + .5,
"C", IF({Price} < 15, {Price} + 2, {Price} * .2)
)
```

Reply

4 Replies 4

Solved
See Solution in Thread

Jul 10, 2021 12:30 AM

Assuming I understood your question, the simplest possible formula is:

```
SWITCH(
{Category},
"A", {Price} * .12,
"B", ({Price} * .09) + .5,
"C", IF({Price} < 15, {Price} + 2, {Price} * .2)
)
```

Reply

Jul 10, 2021 01:12 AM

Thank you so much for the response! That absolutely is the easiest formula and works!

Jul 10, 2021 10:56 AM

Correct. The basic format of the `IF()`

function is:

```
IF(condition, output_if_true, optional_output_if_false)
```

If `{Price} < 15`

isn’t true, then `{Price}`

*must* be >= 15, so the third argument can be executed without the need for checking that condition again.

Jul 10, 2021 11:21 AM

Awesome, that makes total sense, thank you!