This website uses Cookies. Click Accept to agree to our website's cookie use as described in our Privacy Policy. Click Preferences to customize your cookie settings.

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
- Re: 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
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Solved

Jump to Solution

0
995
1

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

Showing results for

Comment Post Options

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Jul 10, 2021 01:12 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Jul 10, 2021 11:21 AM

Awesome, that makes total sense, thank you!