Logical Branching

Learn to create powerful, automated decisions in the data using logical functions and nested rules.

We’ve already learned how to get targeted summaries of our data using conditional aggregations. Now, let’s take that concept a step further: what if we want to add a new column to our dataset that automatically categorizes each row based on a set of rules? This is the core of logical branching. It’s how we transform raw data into meaningful insights, such as automatically labeling customers as Gold, Silver, or Bronze, or flagging an order as “High Priority” based on its value and shipping location. By mastering logical functions, we can build automated decision-making directly into our spreadsheets, allowing us to perform deeper, more strategic analysis.

In this lesson, we’ll explore Google Sheets’s fundamental logical functions, starting with the all-important IF().

Making decisions with IF()

We’ve actually used IF() statements many times in previous lessons, often as a way to check for blank cells or to write simple rules inside other formulas. Here, we’ll look into its syntax and structure because it’s the most important foundational tool for logical branching. The IF() function performs a simple check and then gives one of two results: one if the check is true, and another if it is false. It’s the simplest form of automated decision-making in a spreadsheet. It takes three parameters, as mentioned below.

  • logical_expression: This is the condition we want to check (e.g., C2 > 100).

  • value_if_true: The value to return if the logical_expression is true.

  • value_if_false: The value to return if the logical_expression is false.

Suppose a manager wants to identify which employees met a sales target of $1,000. We can use IF() to automatically label their performance as Met Target or Below Target in a new column. To apply this logic to the first employee, we would enter the formula in cell D3:=IF(C3>=1000, "Met Target", "Below Target").

Press + to interact
Identifying employees who met the sales target
Identifying employees who met the sales target

The IF() function checks if the value in cell C3 is greater than, or equal to 1000. Since it is, it returns Met Target. If we were to drag this formula down, it would apply the same logic to the second employee and the third employee, correctly labeling them as Below Target and Met Target, respectively. This simple but powerful categorization is a core task in data analysis, allowing us to segment our data for deeper insights. ...