← All how-to recipes

How to sum only positive (or only negative) numbers

✓ Verified in LibreOffice 25.8.7.3

Total the gains and losses separately from one mixed column.

The formula

AppFormulaNotes
Excel=SUMIF(A2:A6,">0")Negatives: =SUMIF(A2:A6,"<0"). With no sum range, SUMIF sums the tested range itself.
Google Sheets=SUMIF(A2:A6,">0")Identical.
LibreOffice Calc=SUMIF(A2:A6,">0")Identical.

How it works

SUMIF with ">0" and no separate sum range totals just the positives: 100 + 250 + 30 = 380; "<0" gives the losses (−50 here). Handy companions: the two always reconcile (SUM = positives + negatives), ABS of the negative total gives losses as a positive number, and COUNTIF with the same criteria counts each side.

Verified, not just documented

We ran =SUMIF(A2:A6,">0") in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 380 — exactly the expected result. Every formula here is confirmed by actually executing it.