---
title: "IF function in Excel: syntax and examples | PracticeExcel"
description: "How to use IF in Excel and Google Sheets: pass/fail, bonuses and nested IFs. Syntax, examples and a live drill."
canonical_url: "https://practiceexcelonline.com/functions/if"
locale: en
meta:
  "og:description": "How to use IF in Excel and Google Sheets: pass/fail, bonuses and nested IFs. Syntax, examples and a live drill."
  "og:image": "https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~SUYgZnVuY3Rpb24gaW4gRXhjZWw6IHN5bnRheCBhbmQgZXhhbXBsZXM%2Cdescription_~SG93IHRvIHVzZSBJRiBpbiBFeGNlbCBhbmQgR29vZ2xlIFNoZWV0czogcGFzcy9mYWlsLCBib251c2VzIGFuZCBuZXN0ZWQgSUZzLiBTeW50YXgsIGV4YW1wbGVzIGFuZCBhIGxpdmUgZHJpbGwu%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~SUYobG9naWNhbF90ZXN0LCBbdmFsdWVfaWZfdHJ1ZV0sIFt2YWx1ZV9pZl9mYWxzZV0p%2Cp_Ii9mdW5jdGlvbnMvaWYi%2Cs_z90xF4Nf-DF8SVBf.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "IF function in Excel: syntax and examples | PracticeExcel"
  "twitter:image": "https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~SUYgZnVuY3Rpb24gaW4gRXhjZWw6IHN5bnRheCBhbmQgZXhhbXBsZXM%2Cdescription_~SG93IHRvIHVzZSBJRiBpbiBFeGNlbCBhbmQgR29vZ2xlIFNoZWV0czogcGFzcy9mYWlsLCBib251c2VzIGFuZCBuZXN0ZWQgSUZzLiBTeW50YXgsIGV4YW1wbGVzIGFuZCBhIGxpdmUgZHJpbGwu%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~SUYobG9naWNhbF90ZXN0LCBbdmFsdWVfaWZfdHJ1ZV0sIFt2YWx1ZV9pZl9mYWxzZV0p%2Cp_Ii9mdW5jdGlvbnMvaWYi%2Cs_z90xF4Nf-DF8SVBf.png"
---

> Index of every page on this site: [llms.txt](https://practiceexcelonline.com/llms.txt)

# **The IF function**

Returns one value when a test is TRUE and another when it is FALSE. Put text results in double quotes.

=

IF(

## **Syntax**

```
IF(logical_test, [value_if_true], [value_if_false])
```

<dl><dt>**logical_test **</dt>
<dd>A comparison that is TRUE or FALSE, such as A2&gt;=50.</dd>
<dt>**value_if_true **(optional)</dt>
<dd>What to return when the test is TRUE.</dd>
<dt>**value_if_false **(optional)</dt>
<dd>What to return when the test is FALSE.</dd></dl>

## **Examples**

C1`=IF(<sup>1</sup>A2>=50,<sup>2</sup>"Pass",<sup>3</sup>"Fail")`

|  | A | B | C |
| --- | --- | --- | --- |
| 1 | Score |  | **Pass** |
| 2 | 62 |  | |

**In plain words:** <sup>1</sup>If the score in A2 is 50 or more, <sup>2</sup>show Pass. <sup>3</sup>Otherwise show Fail.

C1=IF(A2>100,A2\*0.1,0)

|  | A | B | C |
| --- | --- | --- | --- |
| 1 | Score |  | **0** |
| 2 | 62 |  | |

## **Practice IF**

- [**1****Pass or fail with IF**→](https://practiceexcelonline.com/practice/if/if-pass-fail)
- [**2****Calculate a bonus with IF**→](https://practiceexcelonline.com/practice/if/if-calculate-bonus)
- [**3****Three outcomes with nested IF**→](https://practiceexcelonline.com/practice/if/nested-if)
- [**4****Compare two cells with IF**→](https://practiceexcelonline.com/practice/if/if-compare-two-cells)

## **Read the guide**

- [**Excel for job interviews: what gets tested and how to prepare**](https://practiceexcelonline.com/learn/excel-for-job-interviews)
- [**Free Excel course online: learn Excel from your first formula to job-ready**](https://practiceexcelonline.com/learn/how-to-learn-excel)
- [**Excel IF formulas: from one condition to many**](https://practiceexcelonline.com/learn/excel-if-function)

## **Questions**

<details>

<summary>

### How many IFs can I nest?

</summary>

Excel allows 64, but past three or four the formula is hard to read. Use IFS, or a lookup table with VLOOKUP or XLOOKUP, instead.

</details>

## **Related functions**

- [**IFS**](https://practiceexcelonline.com/functions/ifs)
- [**AND**](https://practiceexcelonline.com/functions/and)
- [**OR**](https://practiceexcelonline.com/functions/or)
- [**IFERROR**](https://practiceexcelonline.com/functions/iferror)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://practiceexcelonline.com/#identity","@type":"Organization","name":"PracticeExcel","url":"https://practiceexcelonline.com/","logo":{"@id":"https://practiceexcelonline.com/#logo"}},{"@id":"https://practiceexcelonline.com/#website","@type":"WebSite","inLanguage":"en-US","name":"PracticeExcel","url":"https://practiceexcelonline.com/","alternateName":["Practice Excel Online","PracticeExcelOnline.com"],"publisher":{"@id":"https://practiceexcelonline.com/#identity"},"workTranslation":{"@id":"https://excelopgaver.dk/#website"}},{"@id":"https://practiceexcelonline.com/functions/if#webpage","description":"How to use IF in Excel and Google Sheets: pass/fail, bonuses and nested IFs. Syntax, examples and a live drill.","name":"IF function in Excel: syntax and examples","url":"https://practiceexcelonline.com/functions/if","@type":["WebPage","FAQPage"],"breadcrumb":{"@id":"https://practiceexcelonline.com/functions/if#breadcrumb"},"isPartOf":{"@id":"https://practiceexcelonline.com/#website"},"mainEntity":[{"@id":"https://practiceexcelonline.com/functions/if#/schema/question/1"}],"potentialAction":[{"@type":"ReadAction","target":["https://practiceexcelonline.com/functions/if"]}],"primaryImageOfPage":{"@id":"https://practiceexcelonline.com/#logo"}},{"@id":"https://practiceexcelonline.com/functions/if#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://practiceexcelonline.com","position":1},{"@type":"ListItem","name":"Excel functions","item":"https://practiceexcelonline.com/functions","position":2},{"@type":"ListItem","name":"IF function in Excel: syntax and examples","position":3}]},{"@id":"https://practiceexcelonline.com/functions/if#article","description":"How to use IF in Excel and Google Sheets: pass/fail, bonuses and nested IFs. Syntax, examples and a live drill.","headline":"IF function in Excel: syntax and examples","inLanguage":"en-US","thumbnailUrl":"https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~SUYgZnVuY3Rpb24gaW4gRXhjZWw6IHN5bnRheCBhbmQgZXhhbXBsZXM%2Cdescription_~SG93IHRvIHVzZSBJRiBpbiBFeGNlbCBhbmQgR29vZ2xlIFNoZWV0czogcGFzcy9mYWlsLCBib251c2VzIGFuZCBuZXN0ZWQgSUZzLiBTeW50YXgsIGV4YW1wbGVzIGFuZCBhIGxpdmUgZHJpbGwu%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~SUYobG9naWNhbF90ZXN0LCBbdmFsdWVfaWZfdHJ1ZV0sIFt2YWx1ZV9pZl9mYWxzZV0p%2Cp_Ii9mdW5jdGlvbnMvaWYi%2Cs_z90xF4Nf-DF8SVBf.png","@type":["Article","TechArticle"],"author":{"@id":"https://practiceexcelonline.com/#identity"},"image":{"@id":"https://practiceexcelonline.com/#/schema/image/1"},"isPartOf":{"@id":"https://practiceexcelonline.com/functions/if#webpage"},"mainEntityOfPage":{"@id":"https://practiceexcelonline.com/functions/if#webpage"},"publisher":{"@id":"https://practiceexcelonline.com/#identity"}},{"@id":"https://practiceexcelonline.com/functions/if#/schema/question/1","@type":"Question","inLanguage":"en-US","name":"How many IFs can I nest?","acceptedAnswer":{"@type":"Answer","text":"Excel allows 64, but past three or four the formula is hard to read. Use IFS, or a lookup table with VLOOKUP or XLOOKUP, instead."}},{"@id":"https://practiceexcelonline.com/#logo","@type":"ImageObject","caption":"PracticeExcel","contentUrl":"https://practiceexcelonline.com/brand/practiceexcel/icon-512.png","inLanguage":"en-US","url":"https://practiceexcelonline.com/brand/practiceexcel/icon-512.png"},{"@id":"https://practiceexcelonline.com/#/schema/image/1","@type":"ImageObject","contentUrl":"https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~SUYgZnVuY3Rpb24gaW4gRXhjZWw6IHN5bnRheCBhbmQgZXhhbXBsZXM%2Cdescription_~SG93IHRvIHVzZSBJRiBpbiBFeGNlbCBhbmQgR29vZ2xlIFNoZWV0czogcGFzcy9mYWlsLCBib251c2VzIGFuZCBuZXN0ZWQgSUZzLiBTeW50YXgsIGV4YW1wbGVzIGFuZCBhIGxpdmUgZHJpbGwu%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~SUYobG9naWNhbF90ZXN0LCBbdmFsdWVfaWZfdHJ1ZV0sIFt2YWx1ZV9pZl9mYWxzZV0p%2Cp_Ii9mdW5jdGlvbnMvaWYi%2Cs_z90xF4Nf-DF8SVBf.png","inLanguage":"en-US","url":"https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~SUYgZnVuY3Rpb24gaW4gRXhjZWw6IHN5bnRheCBhbmQgZXhhbXBsZXM%2Cdescription_~SG93IHRvIHVzZSBJRiBpbiBFeGNlbCBhbmQgR29vZ2xlIFNoZWV0czogcGFzcy9mYWlsLCBib251c2VzIGFuZCBuZXN0ZWQgSUZzLiBTeW50YXgsIGV4YW1wbGVzIGFuZCBhIGxpdmUgZHJpbGwu%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~SUYobG9naWNhbF90ZXN0LCBbdmFsdWVfaWZfdHJ1ZV0sIFt2YWx1ZV9pZl9mYWxzZV0p%2Cp_Ii9mdW5jdGlvbnMvaWYi%2Cs_z90xF4Nf-DF8SVBf.png"}]}
```

## Sitemap

See the full [sitemap](https://practiceexcelonline.com/sitemap.md) for all pages.
