Guides
/

Math

COUNTIF

How to use COUNTIF and SUMIF in Excel: count and sum by condition

COUNTIF returns the number of cells that meet a condition, and SUMIF returns the sum of numbers in the rows that meet it.

Syntax

=COUNTIF(range, criteria)
  • range — The cells to test against the condition.
  • criteria — A number, text or expression: "Tashkent", ">100", "<>0".

Example

AB
1OrderRegion
2#101Tashkent
3#102Samarkand
4#103Tashkent

Formula:

=COUNTIF(B2:B4,"Tashkent")

→ result: 2

Writing criteria

Comparison operators go inside quotes: ">300000". To compare with a value in a cell, use &: ">"&E1.

SUMIF

=SUMIF(B2:B10,"Tashkent",C2:C10) adds up the values in column C for rows where column B contains “Tashkent”.

Multiple conditions

For several conditions, use COUNTIFS and SUMIFS: =SUMIFS(C2:C10,B2:B10,"Tashkent",D2:D10,">=2026-01-01").

Frequently asked questions

No, “tashkent” and “TASHKENT” are treated the same.
=COUNTA(A2:A100) or =COUNTIF(A2:A100,"<>").