Sheet Clinic

Google Sheets COUNTIF with OR: count one value or another

For COUNTIF OR, add two COUNTIFs or use SUMPRODUCT with the values in braces. COUNTIFS on one column returns 0. Plus OR with an AND condition.

Sheet Clinic editorsPublished
G2=COUNTIFS(C2:C, "Late", C2:C, "Absent")

Before as you see it

ABCDFG
1NameDayCodeShiftWhat we countCount
2EmilyMonPresentDayLate or Absent (COUNTIFS)0
3JacobMonLateNightLate or Absent (one COUNTIF)0
4SarahMonAbsentDayNight shift, Late or Absent0
5MichaelMonPresentNightRows in the log16
6EmilyTueLateDay
7JacobTuePresentNight
8SarahTuePresentDay
9MichaelTueAbsentNight
10EmilyWedPresentDay
11JacobWedLateNight
12SarahWedExcusedDay
13MichaelWedLateNight
14EmilyThuPresentDay
15JacobThuAbsentNight
16SarahThuLateDay
17MichaelThuPresentNight

What changed

  1. G2 two COUNTIFs added
  2. G3 SUMPRODUCT around a list
  3. G4 the list plus Night

After Fixed tab

ABCDFG
1NameDayCodeShiftWhat we countCount
2EmilyMonPresentDayLate or Absent (two COUNTIFs)8
3JacobMonLateNightLate or Absent (list in braces)8
4SarahMonAbsentDayNight shift, Late or Absent5
5MichaelMonPresentNightRows in the log16
6EmilyTueLateDay
7JacobTuePresentNight
8SarahTuePresentDay
9MichaelTueAbsentNight
10EmilyWedPresentDay
11JacobWedLateNight
12SarahWedExcusedDay
13MichaelWedLateNight
14EmilyThuPresentDay
15JacobThuAbsentNight
16SarahThuLateDay
17MichaelThuPresentNight
Figure 1. The same 16 attendance rows on both tabs. Only the formulas in G2:G4 differ.

Add one COUNTIF per value, with a plus sign between them, to count the rows where a column holds one value or another. A single COUNTIFS that names both values for the same column returns 0 instead. On the attendance log in Figure 1, the Fixed tab has =COUNTIF(C2:C, "Late") + COUNTIF(C2:C, "Absent") in G2, and it returned 8: five Late rows plus three Absent rows. A cell in column C holds a single code, so no row can match both halves, and none is counted twice. The only parts to swap for another log are C2:C, the column being counted, and the two quoted words. With three or more values, a list in braces inside SUMPRODUCT and COUNTIF saves repeating the function, as the first section shows.

On the Broken tab, G2 holds =COUNTIFS(C2:C, "Late", C2:C, "Absent") instead. Sheets calculates it and puts a plain 0 in the cell, with no error and no warning triangle. COUNTIFS takes pairs of a range and a condition and counts a row only when all of its pairs hold. Both pairs here test column C, so C3 would have to equal Late and Absent at the same time.

G3 on that tab tries =COUNTIF(C2:C, "Late OR Absent") and also returned 0. Google's COUNTIF page gives ? and * as the wildcard characters for text, and OR is not one of them, so Sheets looked for a cell whose whole text is Late OR Absent. Column C has none.

The Broken tab with G2 selected. The formula bar shows =COUNTIFS(C2:C, "Late", C2:C, "Absent"). G2, G3 and G4 show 0 and G5 shows 16.
Figure 2. The Broken tab. All three counts in G2:G4 are 0, with nothing flagged.

More than two values, with a list in braces inside SUMPRODUCT and COUNTIF

Once there are more than two codes, a shorter form puts them in curly braces. =SUMPRODUCT(COUNTIF(C2:C, {"Late", "Absent"})) in G3 of the Fixed tab also returned 8. The braces hand COUNTIF a small list, COUNTIF returns one count per item, and SUMPRODUCT adds those counts.

The outer function matters here. B2 on the More cases tab uses SUM instead and returned 5, which is the Late count alone, and nothing on screen marks it as wrong. The bare list with no function around it, in B4, returned 5 as well. Wrapping the SUM version in ARRAYFORMULA, as B3 does, brought it back to 8.

The More cases tab with B2 selected. The formula bar shows =SUM(COUNTIF(Fixed!C2:C, {"Late", "Absent"})) and B2 shows 5. B3 shows 8 and B4 shows 5.
Figure 3. SUM around the list returned 5, the Late count alone. B3 with ARRAYFORMULA returned 8.

The #N/A in B5 of that figure is one more attempt, =COUNTIF(Fixed!C2:C, "Late", "Absent"), with the second code passed as a third argument. Selecting the cell brings up this note: Wrong number of arguments to COUNTIF. Expected 2 arguments, but got 3 arguments.

Input16 attendance rows, codes in column C, shifts in column D
Formula=SUMPRODUCT(COUNTIF(C2:C, {"Late", "Absent"}))
Expected8
Sheets returned8 Matches expected
Checked2026-11-11, free personal account

Adding an AND condition from another column: COUNTIFS around the list in braces

Column D gives each row a shift. Jacob and Michael work nights, Emily and Sarah work days. G4 asks how many Night rows are Late or Absent, which is an OR inside column C and an AND with column D. Since COUNTIFS already joins its pairs with AND, the shift goes in as an ordinary pair and the OR stays in the braces.

The Fixed tab has =SUMPRODUCT(COUNTIFS(C2:C, {"Late", "Absent"}, D2:D, "Night")), and it returned 5. Sheets ran COUNTIFS once for Late with Night, matching Jacob on Monday and Wednesday and Michael on Wednesday, then once for Absent with Night, matching Michael on Tuesday and Jacob on Thursday. SUMPRODUCT added the 3 and the 2. The broken G4 had kept the impossible Late-and-Absent pair with Night stacked on top, and an extra pair can only remove rows, so it stayed at 0. The COUNTIFS page also requires every added range to have the same number of rows and columns as the first; C2:C and D2:D both start at row 2 and run to the bottom, so they line up.

The Fixed tab with G4 selected. The formula bar shows =SUMPRODUCT(COUNTIFS(C2:C, {"Late", "Absent"}, D2:D, "Night")). G2 and G3 show 8, G4 shows 5 and G5 shows 16.
Figure 4. The Fixed tab. G4 counts Night rows that are Late or Absent.

The Try it yourself tab is the Broken tab again, three zeros included. Put =COUNTIF(C2:C, "Late") + COUNTIF(C2:C, "Absent") in G2, =SUMPRODUCT(COUNTIF(C2:C, {"Late", "Absent"})) in G3, and =SUMPRODUCT(COUNTIFS(C2:C, {"Late", "Absent"}, D2:D, "Night")) in G4. G2:G4 should then read 8, 8 and 5, the same as the Fixed tab.

OR across two columns counts some rows twice when COUNTIFs are added

Adding COUNTIFs is safe while both conditions test the same column. Across two columns, one row can meet both conditions and get counted twice. Row 3 is Jacob, Late, Night, and a count of rows that are Late or on the Night shift should include him once.

B6 on the More cases tab adds COUNTIF(Fixed!C2:C, "Late") and COUNTIF(Fixed!D2:D, "Night"), and it returned 13: 5 Late rows plus 8 Night rows. Three rows are Late and Night together, so they were counted twice, and the real number of rows is 10.

B7 returned 10 with =SUMPRODUCT(--(((Fixed!C2:C="Late") + (Fixed!D2:D="Night")) > 0)). Each comparison gives TRUE or FALSE per row, and adding the two turns that into a score of 0, 1 or 2. The > 0 test turns any row with at least one match into TRUE, the double minus turns TRUE into 1, and SUMPRODUCT adds the ones. Jacob's Monday row scores 2 and still adds just 1.

A trailing space, lowercase and a wildcard in the COUNTIF criterion

Column E of the More cases tab tests how exactly a typed code has to match. It holds Late in E2, Late followed by a space in E3, and late in lowercase in E4. =COUNTIF(E2:E4, "Late") returned 2: lowercase matched, since COUNTIF is not case sensitive, and the trailing space did not. =COUNTIF(E2:E4, "Late*") returned 3, because the asterisk also covers the space. Matching on part of the text is the subject of COUNTIF with wildcards and "if cell contains".

Take-home copy. Four tabs: Broken (as you see it), Fixed, Try it yourself, More cases. It opens as a copy in your own Drive.

Copy the sheet