How to count attendance in Excel
Formula (Excel and Google Sheets)
=COUNTIF(B2:F2,"P")Count each student's "P" marks across the day columns: =COUNTIF(B2:F2,"P"), filled down.
- Result on the example
- one result per row in
G2, filled down toG7 - Works in
- Every current version
- Google Sheets
- Same formula
See it work
The formula is already in G2, filled down to G7. Change any input and the result updates, or edit the formula to experiment.
How it works
Each row is one student and each column one school day. COUNTIF looks along the row and counts the cells marked "P". Because the range has no $ signs, it moves down a row with each student.
Late (L) and absent (A) are not counted as present here; Ben was present 3 of 5 days.
=COUNTIF(B2:F2,"P")Result5
B2:F21 row × 5 cols: "P", "P", "P", "P", …A range: 5 cells in one row.
COUNTIF(B2:F2,"P")5COUNTIF: Counts cells that meet one condition.- range
B2:F21 row × 5 cols: "P", "P", "P", "P", … - criteria
"P"
- range
In Google Sheets
The same formula works in Google Sheets: =COUNTIF(B2:F2,"P"). We ran it in Google Sheets mode on the same data and it returns the same results.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =SUMPRODUCT(--(B2:F2="P")) | 5, 3, 4… | The same count with a comparison. Use it with EXACT if lowercase "p" must not count. |
| =COUNTIF(B2:F2,"P")+COUNTIF(B2:F2,"L") | 5, 4, 4…Different result | Counts late arrivals as present. Ben and Eve get one more day each for their late marks. |
Common mistakes
- COUNTIF ignores case, so "p" and "P" both count. Use a drop-down list to keep the codes consistent.
- Blank cells (days not recorded yet) count as neither present nor absent. Count the days recorded with
=COUNTA(B2:F2).
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Count attendance
G2, count the days the student was marked present (P), then fill down to G7.Questions
How do I calculate the attendance percentage?
Divide by the days recorded: =COUNTIF(B2:F2,"P")/COUNTA(B2:F2), formatted as a percentage.
How do I count how many students were present each day?
Count down the column instead: =COUNTIF(B2:B7,"P"), filled across.
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.