← All how-to recipes

How to count only visible rows after filtering

✓ Verified in LibreOffice 25.8.7.3

A count that respects the filter — "showing N of M records".

The formula

AppFormulaNotes
Excel=SUBTOTAL(103,A2:A1000)103 = COUNTA over visible rows only. Put it ABOVE the data or beside it, not in a filterable row.
Google Sheets=SUBTOTAL(103,A2:A1000)Identical.
LibreOffice Calc=SUBTOTAL(103,A2:A1000)Identical.

How it works

Plain COUNTA keeps counting rows a filter has hidden; SUBTOTAL with the 100-series COUNTA code (103) counts only what's visible (all 3 here since nothing's filtered — apply a filter and the number drops live). A "showing X of Y" header is =SUBTOTAL(103,A2:A1000)&" of "&COUNTA(A2:A1000). Codes 109/101 do the same for SUM/AVERAGE, and the full code table lives in the SUM-vs-SUBTOTAL comparison. Place the formula outside the filtered range or it can hide itself.

Verified, not just documented

We ran =SUBTOTAL(103,A2:A4) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 3 — exactly the expected result. Every formula here is confirmed by actually executing it.