# IF with boolean logic

= IF(criteria1*criteria2*criteria3,result)

In the example shown, the formula in F8 is:

*Note: this is an array formula, and must be entered with control + shift + enter.*

*Note: This example demonstrates how to replace a nested IF formula with a single IF in an array formula using boolean logic. This technique can be used to reduce complexity in complex formulas. However, the example is for illustration only. This particular problem could be easily solved with SUMIFS or SUMPRODUCT.*

The formulas in F7 and F8 return the same result, but have different approaches. In cell F7, we have the following formula, using a nested IF approach:

This is how Excel evaluates the IFs inside SUM:

In essence, each IF "filters" values into the next IF, and only quantities where all three logical tests return TRUE "survive" the operation. Other quantities become FALSE and are evaluated by SUM as zero. The final result inside SUM is an array of values like this:

=SUM({FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;8;FALSE;10})

FALSE values evaluate to zero, and the SUM function returns a final result of 18.

In F8 we have this formula, which uses a single IF and boolean logic:

Each logical expression returns a an array of TRUE and FALSE values. When these arrays are multiplied together, the math operation coerces values to ones and zeros in a single array like this:

IF({0;0;0;0;0;0;1;0;1},quantity)

The array of 1s and 0s filters out irrelevant data, and the same result delivered to SUM:

=SUM({FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;8;FALSE;10})

As before, SUM returns a final result of 18.

## Excel Formula Training

Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.

## Download 200+ Excel Shortcuts

Get over 200 Excel shortcuts for Windows and Mac in one handy PDF.