Excel Supreme

Excel track · Exercise 4 of 86 Paid

Add only the positives

Total the positive and negative rows separately instead of netting a column.

Intermediate

Monthly changes and weekly variances

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

In B7, add up the months that went up and leave the drops alone.

AB
1MonthChange
2Jan12
3Feb-8
4Mar15
5Apr-3
6May20
7Gains

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

B7

What it does

A plain SUM over a profit-and-loss column returns the net, which is the least informative figure in it. SUMIF splits the column by sign instead: ">0" keeps the gains and "<0" keeps the drops.

Zero belongs to neither bucket, so a flat month vanishes from both totals and the pair will not add back to the net. A net that misses the column by one month's figure is that missing zero.

The second screen puts a minus in front of the function so the losses read as a size rather than a negative. The minus does not change which rows matched, so a wrong condition still shows up as the wrong size.

Syntax

=SUMIF(range, ">0") and =-SUMIF(range, "<0")

Worked example

On Monthly changes and weekly variances, =SUMIF(B2:B6,">0") returns 47.

=SUMIF(B2:B6,">0")

Common errors

Error codes for SUMIF with a sign comparison, and flipping a negative total
ErrorWhat it means and how to fix it
#VALUE!The criteria range holds text that cannot be compared with a number, or a comparison lost its quotes and is read as a cell reference.
#NAME?The function is misspelled, or SUMIFS was used with the argument order SUMIF keeps.
Wrong signLosses are negative, so a report that wants their size needs the minus in front of SUMIF. Without it the figure reads as -15 rather than 15.

At work

A monthly variance report that shows total gains and total losses on separate lines.