How to sum values by category (conditional sum) with SUMIF
✓ Verified in LibreOffice 25.8.7.3Add up only the numbers whose row matches a category or label, e.g. total spend for 'Books'.
The formula
| App | Formula | Notes |
|---|---|---|
| Excel | =SUMIF(A2:A6,"Books",B2:B6) | Works in all Excel versions. |
| Google Sheets | =SUMIF(A2:A6,"Books",B2:B6) | Identical syntax. |
| LibreOffice Calc | =SUMIF(A2:A6,"Books",B2:B6) | Fully supported. |
How it works
SUMIF(range, criteria, sum_range) adds every value in sum_range whose matching cell in range meets the criteria. Here the three 'Books' rows (10 + 7 + 2) total 19. For multiple conditions, use SUMIFS.
Verified, not just documented
We ran =SUMIF(A2:A6,"Books",B2:B6) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 19 — exactly the expected result. Every formula here is confirmed by actually executing it.