In this article:

May 8, 2024

Google Sheets doesn't directly use the term "ternary" in the way programming languages do, but you can achieve similar conditional logic using the IF function which acts like a ternary operator found in many programming languages. The ternary operator is a shortcut for the if statement, which is used to execute different code based on a condition being true or false.

It typically looks something like this in programming: ‘**condition ? exprIfTrue : exprIfFalse.’**

In Google Sheets, the IF function allows you to specify a condition and then return one value if the condition is true, and another if the condition is false. This is similar to how the ternary operator works.

The syntax for the IF function in Google Sheets is:

**IF(condition, value_if_true, value_if_false)**

Here's a basic example:

You want to check if the number in cell A1 is greater than 10. If it is, you want to return "Greater than 10"; otherwise, you want to return "10 or less".

You would use the following formula in Google Sheets:

**=IF(A1 > 10, "Greater than 10", "10 or less")**

This formula checks the condition (A1 > 10). If the condition is true, it returns "Greater than 10". If the condition is false, it returns "10 or less", acting like a ternary operation.

Follow the steps below to easily use Google Sheets Ternary or the IF function.

In our example, click on cell B2 where you want to display the first result of the ternary operation (IF function) based on the score in A2.

Type '=' followed by 'IF(' into cell B2 to begin your formula.

After 'IF(', type your condition that compares the score in A2. For this example, use 'A2 > 60' to check if the score is greater than 60.

Type a comma , after your condition and then "Pass" to indicate the value you want to return if the condition is true. Since "Pass" is text, enclose it in double quotes.

After specifying the true result, type another comma , and then "Fail" for the false condition. Complete the formula with a closing parenthesis ).

Hit Enter to execute the formula. Google Sheets will evaluate the condition in B2 and display "Pass" if the score is above 60, and "Fail" if it's not.

Drag the fill handle (the small square at the bottom right corner of cell B2) down to C10 to apply the ternary logic to all scores listed in column B.

If necessary, you can modify the formula in any cell within column C to change conditions, or adjust the "Pass" and "Fail" criteria based on different score thresholds.

We hope that you now have a better understanding of what Google Sheets Ternary is and how to use it. If you enjoyed this article, you might also like our article on how to create a task tracker in Google Sheets or our article on how to draw on Google Sheets.

Get Google Sheets productivity and automation tips delivered straight to your inbox

We'll email you 1-3 times a week — and never share your information.

Get your copy of our free Google Sheets automation guide!

- 27 pages of Google Sheets tips and tricks to save time
- Covers pivot tables and other advanced topics
- 100% free

Use Lido to connect your spreadsheets to email, Slack, calendars, and more to automate data transfers and eliminate manual copying and pasting. View all use cases ->