> ## Documentation Index
> Fetch the complete documentation index at: https://help.dingtalk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Using IF and IFS

> 📌 More functions: see the formula function reference.

> 📌 More functions: see the [Formula function reference](/aitable/formulas/function-reference).

# 1 Basics

**IF** and **IFS** are common AI Table logical functions — return different values or take different actions based on conditions.

### IF

**IF** lets you specify a condition and return different results based on whether it's true. It's one of the most basic logical tools in spreadsheets.

#### Syntax

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
IF(condition, [if_true], [if_false])
```

* **condition**: the logical expression to test.
* **if\_true**: value to return when the condition is true.
* **if\_false**: value to return when the condition is false.

#### Example

\[Field 1] in the first record is **50**.

##### Example 1: is \[Field 1] > 30?

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
=IF([Field 1] > 30, "Pass", "Fail")
```

Result: **"Pass"** (50 > 30).

### IFS

**IFS** is an extension of **IF** — test multiple conditions and return the first match. Cleaner than nested **IF**s.

#### Syntax

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
IFS(condition1, value1, condition2, value2, ..., [default])
```

* **condition1, condition2, ...**: a series of logical expressions to test.
* **value1, value2, ...**: values to return when the corresponding condition is true.
* **default** (optional): value to return when no condition matches.

#### Example

\[Field 1] in the first record is **75**.

##### Example 1: grade by score range

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
=IFS([Field 1] >= 90, "Excellent", [Field 1] >= 70, "Good", [Field 1] >= 60, "Pass", TRUE, "Fail")
```

Result: **"Good"** (75 matches the second condition). With **IF** and **IFS**, you can build complex logical decisions and data handling — fits a wide range of business needs.

# 2 FAQ

* **Q**: Why does an IFS() formula have no syntax error but return #N/A?

  **A**: When the input doesn't match any condition in IFS(), it returns #N/A. Add a fallback at the end. Example: **IFS(\[Score]=100,"Full marks", \[Score] >=85,"Excellent", \[Score] >=75,"Good", \[Score] >=60,"Pass", TRUE,"Fail")** — here **TRUE,"Fail"** is the fallback. Anything that misses the earlier conditions falls into "Fail".
