Spreadsheet Practice

How to calculate the percentage within each group using COUNTIFS in Excel

Formula (Excel and Google Sheets)

=COUNTIFS($B$2:$B$13,E2,$C$2:$C$13,"Remote")/COUNTIF($B$2:$B$13,E2)

Count the group's rows that meet the condition and divide by all the group's rows: =COUNTIFS($B$2:$B$13,E2,$C$2:$C$13,"Remote")/COUNTIF($B$2:$B$13,E2).

Result on the example
one result per row in F2, filled down to F4
Works in
Every current version
Google Sheets
Same formula

See it work

The formula is already in F2, filled down to F4. Change any input and the result updates, or edit the formula to experiment.

How it works

The top of the fraction counts people in the department who work remotely: COUNTIFS with two conditions. The bottom counts everyone in the department with COUNTIF. Sales has 5 people and 2 work remotely: 40%. Each department is compared with its own size, not with the whole company.

=COUNTIFS($B$2:$B$13,E2,$C$2:$C$13,"Remote")/COUNTIF($B$2:$B$13,E2)

Result0.4

  1. $B$2:$B$1312 rows × 1 col: "Sales", "Sales", "IT", "IT", …

    A range: 12 cells in one column.

  2. E2"Sales"

    The value in E2.

  3. $C$2:$C$1312 rows × 1 col: "Remote", "Office", "Remote", "Remote", …

    A range: 12 cells in one column.

  4. COUNTIFS($B$2:$B$13,E2,$C$2:$C$13,"Remote")2

    COUNTIFS: Counts rows that meet every condition.

    • criteria_range1$B$2:$B$1312 rows × 1 col: "Sales", "Sales", "IT", "IT", …
    • criteria1E2"Sales"
    • criteria_range2$C$2:$C$1312 rows × 1 col: "Remote", "Office", "Remote", "Remote", …
    • criteria2"Remote"
  5. COUNTIF($B$2:$B$13,E2)5

    COUNTIF: Counts cells that meet one condition.

    • range$B$2:$B$1312 rows × 1 col: "Sales", "Sales", "IT", "IT", …
    • criteriaE2"Sales"
  6. COUNTIFS($B$2:$B$13,E2,$C$2:$C$13,"Remote")/COUNTIF($B$2:$B$13,E2)0.4

    The / operator divides.

In Google Sheets

The same formula works in Google Sheets: =COUNTIFS($B$2:$B$13,E2,$C$2:$C$13,"Remote")/COUNTIF($B$2:$B$13,E2). 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.

FormulaResultWhen to use it
=COUNTIFS($B$2:$B$13,E2,$C$2:$C$13,"Remote")/COUNTA($B$2:$B$13)16.7%, 25.0%, 8.3%Different resultDivides by the whole company: the department's remote workers as a share of all employees. Gives Sales 16.7% (2 of 12).

Common mistakes

  • Dividing by the company total answers a different question: what share of all staff are remote workers in that department.
  • A department with no rows makes COUNTIF return 0 and the formula #DIV/0!. Wrap it in IFERROR.

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.

Calculate the percentage within each group using COUNTIFS

In F2, calculate the percentage of the department in E2 that works remotely, then fill down to F4.

Questions

How do I put the condition in a cell?

Reference it: =COUNTIFS($B$2:$B$13,E2,$C$2:$C$13,$G$1)/COUNTIF($B$2:$B$13,E2), with "Remote" in G1.

Can a pivot table show this?

Yes: Department in Rows, Work mode in Columns, a count in Values, then Show Values As, % of Row Total.

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.