How to sum only positive (or only negative) numbers
✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)Total the gains and losses separately from one mixed column.
The formula
| App | Formula | Notes |
|---|---|---|
| Excel (desktop) | =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. We then ran the same formulas in Google Sheets, executed 2026-08-30: a formula-only workbook goes into Google Drive, which converts it to a Sheet and recalculates every formula with Google’s own engine, and comes back out as .xlsx carrying the values Google computed. It returned 380 for the worked example, the same value LibreOffice produced. Both engines’ numbers on this page are executed results. The Excel formula follows Microsoft’s official documented syntax — we do not run desktop Excel.
Functions used
SUMIF — see full Excel, Google Sheets & LibreOffice compatibility for each.
Related recipes
- How to use the SUMIF function
- How to sum values by category (conditional sum) with SUMIF
- How to sum values where a checkbox is checked
- How to sum where another column is not blank
- How to sum with multiple criteria (SUMIFS)