← All how-to recipes

How to SUMIF across a row (horizontal SUMIF)

✓ Verified in LibreOffice 25.8.7.3

Conditional sums when your categories run left-to-right instead of top-to-bottom.

The formula

AppFormulaNotes
Excel=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. Every formula here is confirmed by actually executing it.