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
- Creating an IF statement to return values under ce...

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

Topic Labels:
Formulas

Solved

Jump to Solution

0
764
7

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

May 27, 2022 10:06 AM

I need to create an IF statement that works with the following logic:

If the value of column X is less than the value of column Y, it needs to return the value of column X.

If the value of column X is greater than the value of column Y, the IF statement needs to subtract the value of column Y by the value of column X.

Can someone please 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

May 30, 2022 01:35 PM

Hi @Christyan_Matos!

First, I’ve opened this topic a few times and seeing that **a)** @Vivid-Squid had answered and **b)** seen that your response contained a quote block, I erroneously thought the question remaining the same. I’m sure a few others have done the same for the same reason. It helps when people **only use** the quote function when the text within the quote block remains the **exact same** as the quoted text. If you supply new text or info, do that outside of a quote block.

IF formulas work like this

```
IF({Condition},
{condition is true},
{condition is false}
)
```

Outputs of an IF formula can be **text**, a **field value** or an **action**.

If **text** you write the text within quotation marks, e.g. `'desired output'`

If **field value** you wrap the desired field name within curly brackets, e.g. `{field name}`

.

If **action** you simply type your desired formula, e.g. `desired formula`

You can nest IF statements, like in your case

```
IF({is X greater than the value of column Y},
[True] {Y},
[False] IF({is X equal to Y},
[True] {X},
[False] {X}
)
)
```

[True] and [False] are there for teaching purposes and should not be there in the actual formula.

Using this; in your case the formula then ends up being

```
IF(X>Y,
Y,
IF(X=Y,
X,
X
)
)
```

When you understand the basics you can simplify your formula. In case of comparing numbers Airtable allows us to use `>=`

**Greater than or equal to** and `<=`

**Less than or equal to**, like @Vivid-Squid did in his answer, which allows us to state your formula as

```
IF({is Y greater than or equal to X},
{X},
{Y}
)
```

And the done formula.

```
IF(Y>=X,
X,
Y
)
```

You can find all kinds of formula functions here in the formula field reference guide.

I hope that made sense and helped you.

Reply

7 Replies 7

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

May 27, 2022 10:08 AM

Hi @Christyan_Matos

I am happy to help you. One quick question, what do you want to do if X = Y?

Reply

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

May 27, 2022 10:11 AM

Thank you very much for the return, in this case, if it is equal, repeat the value of column X.

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

May 27, 2022 10:14 AM

Got it, try this.

```
IF(X<=Y, X, Y-X)
```

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

May 27, 2022 10:23 AM

It turned out great, thank you very much.

Reply

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

May 27, 2022 04:49 PM

A question, considering this scenario:

If the value of column X is greater than the value of column Y, an IF statement must return the value of column Y.

If the value of column X is less than the value of column Y, you must return the value of column X.

If X = Y, repeat the value of column X.

Thanks.

Solved
See Solution in Thread

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

May 30, 2022 01:35 PM

Hi @Christyan_Matos!

First, I’ve opened this topic a few times and seeing that **a)** @Vivid-Squid had answered and **b)** seen that your response contained a quote block, I erroneously thought the question remaining the same. I’m sure a few others have done the same for the same reason. It helps when people **only use** the quote function when the text within the quote block remains the **exact same** as the quoted text. If you supply new text or info, do that outside of a quote block.

IF formulas work like this

```
IF({Condition},
{condition is true},
{condition is false}
)
```

Outputs of an IF formula can be **text**, a **field value** or an **action**.

If **text** you write the text within quotation marks, e.g. `'desired output'`

If **field value** you wrap the desired field name within curly brackets, e.g. `{field name}`

.

If **action** you simply type your desired formula, e.g. `desired formula`

You can nest IF statements, like in your case

```
IF({is X greater than the value of column Y},
[True] {Y},
[False] IF({is X equal to Y},
[True] {X},
[False] {X}
)
)
```

[True] and [False] are there for teaching purposes and should not be there in the actual formula.

Using this; in your case the formula then ends up being

```
IF(X>Y,
Y,
IF(X=Y,
X,
X
)
)
```

When you understand the basics you can simplify your formula. In case of comparing numbers Airtable allows us to use `>=`

**Greater than or equal to** and `<=`

**Less than or equal to**, like @Vivid-Squid did in his answer, which allows us to state your formula as

```
IF({is Y greater than or equal to X},
{X},
{Y}
)
```

And the done formula.

```
IF(Y>=X,
X,
Y
)
```

You can find all kinds of formula functions here in the formula field reference guide.

I hope that made sense and helped you.

Reply

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

May 31, 2022 10:32 AM