← All how-to recipes

How to find the maximum value that meets a condition (MAX IF)

✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)

Get the largest number in a range, but only for rows that match a criterion.

The formula

AppFormulaNotes
Excel (desktop)=MAXIFS(B2:B5,A2:A5,"North")MAXIFS(max_range, criteria_range, criteria). Excel 2019+.
Google Sheets=MAXIFS(B2:B5,A2:A5,"North")Identical.
LibreOffice Calc=MAXIFS(B2:B5,A2:A5,"North")Identical (LibreOffice 5.2+).

How it works

MAXIFS returns the maximum of B2:B5 restricted to the rows where A2:A5 equals 'North'. Those values are 10, 30 and 20, so the result is 30 - the South row's 50 is ignored. Use MINIFS the same way for a conditional minimum.

Verified, not just documented

We ran =MAXIFS(B2:B5,A2:A5,"North") 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

MAXIFS — see full Excel, Google Sheets & LibreOffice compatibility for each.