Excel Supreme

Excel track · Exercise 28 of 86 Paid

Logical functions: putting the pieces together

Combine a logical test, a combined test and a rounded calculation in one formula.

Advanced

Stock list with a total row, and a price column to average

Read-only data · screen 1 of 2 · answer in B9

In B9, put PASS in the cell when the total is over 100 and no item is under 15 units, otherwise FAIL.

AB
1ItemUnits
2Bolt18
3Nut22
4Washer25
5Screw30
6Clip24
7Pin31
8Total150
9Verdict

Download this grid (.xlsx) Two tabs: the grid you see, and the answer.

B9

What it does

The two formulas here put the earlier pieces together. The first nests AND inside IF: both tests are checked and the cell answers PASS or FAIL rather than TRUE or FALSE. The second wraps an average in ISNUMBER before rounding it, so a price column with no numbers returns none instead of an error.

On the first screen the total is 150 and the smallest item is 18, so both tests hold and B9 reads PASS. The second screen averages six prices to 4.3166 and rounds that to 4.3. Every figure comes from the grid, so a corrected price moves the answer without the formula changing.

ROUND changes the value while cell formatting changes only the look, so a rounded figure can be summed and a formatted one still carries its decimals underneath. A guard on the calculation names the condition that could fail, which reads better than IFERROR over the whole formula.

Syntax

=IF(AND(test 1, test 2),"PASS","FAIL"); =IF(ISNUMBER(AVERAGE(range)),ROUND(...,1),"none")

Worked example

On Stock list with a total row, and a price column to average, =IF(AND(B8>100,MIN(B2:B7)>=15),"PASS","FAIL") returns PASS.

=IF(AND(B8>100,MIN(B2:B7)>=15),"PASS","FAIL")

Common errors

Error codes for nesting AND inside IF, and guarding a calculation with ISNUMBER before ROUND
ErrorWhat it means and how to fix it
#VALUE!The finished text result was used in arithmetic, as when PASS is divided by zero.
#DIV/0!AVERAGE found no numbers in C2:C7 and divided a zero total by a count of zero.
#NAME?One of the nested function names was mistyped, so the whole formula fails.

At work

Printing a rounded average with a word in place of an error when a month has no data.