In this article:

Google Sheets Ternary (Easiest Way to Use It in 2024)

May 8, 2024

What is Google Sheets Ternary

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.

How to Use Google Sheets Ternary (IF Function)

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

1. Click on a Cell to Display Results

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.

google sheets ternary

2. Begin IF Formula in Cell B2

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

3. Type Condition to Compare Score in B2

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.

4. Enter "Pass" for Scores Above 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.

5. Enter "Fail" for Scores 60 or Below

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

6. Execute the Formula by Pressing Enter

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.

7. Apply Ternary Logic to All Scores by Dragging Down

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.

8. Modify Formula for Different Conditions as Required

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
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
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

Work less, automate more!

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 ->