How to SUMIF across a row (horizontal SUMIF)
✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)Conditional sums when your categories run left-to-right instead of top-to-bottom.
The formula
| App | Formula | Notes |
|---|---|---|
| Excel (desktop) | =SUMIF(B1:H1,"Q1",B2:H2) | Criteria range and sum range are both horizontal โ SUMIF doesn't care about orientation, only that shapes match. |
| Google Sheets | =SUMIF(B1:H1,"Q1",B2:H2) | Identical. |
| LibreOffice Calc | =SUMIF(B1:H1,"Q1",B2:H2) | Identical. |
How it works
SUMIF works sideways exactly as it does vertically โ the header row is the criteria range and the numbers row is the sum range: the two Q1 columns contribute 10 + 20 = 30. The only real rule is that both ranges must have the same shape and alignment. COUNTIF/AVERAGEIF/SUMIFS are equally orientation-agnostic; people just rarely see horizontal examples.
Verified, not just documented
We ran =SUMIF(B1:E1,"Q1",B2:E2) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 30 — 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 30 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 only positive (or only negative) numbers
- How to sum where another column is not blank