A simple way to do this is with the COUNTIFS function.

COUNTIFS function

TheCOUNTIFS functionis designed to count things based on more than one condition.

Forcriteria1, we use themixed reference$F5.

Two-way summary count criteria setup

Cell F5 contains the value “Engineering”, which will be used for criteria.

We leave the row relative because we want the row to change as we copy the formula down.

Forcriteria2, we use themixed referenceG$4.

Two-way summary count criteria setup

Cell G4 contains the value “A”, which will be used for criteria.

This is the final formula entered in cell G5, and copied into the range G5:H8.

To recap, the named rangesdeptandgroupautomatically behave like absolute references and will not change.

Two-way summary count criteria setup

The references to $F5 and G$4 however are mixed.

Excel Tables usestructured references, which appear automatically in formulas that refer to them.

One of the videos shows an easy way to lock a structured reference.

Two-way summary count criteria setup

If you are new to Excel Tables, seeWhat is an Excel Table?

TheLET functionis used to assign all three intermediate results to the variablesdepts,groups, andcounts.

Next, theHSTACKandVSTACKfunctions are used to assemble the final table.

Two-way summary count criteria setup

To learn more about how to convert a formula to use LET, see thisdetailed LET function example.

As a bonus, there is no need to lock specific cell references.

Seethis examplefor another related problem with a more complete walkthrough.

Two-way summary count with an excel table

All in one formula with new dynamic array functions

Excel formula: Summary count with COUNTIF

Excel formula: Summary count by month with COUNTIFS

Excel formula: Summary count with percentage breakdown

Excel COUNTIFS function

Excel LET function

Excel UNIQUE function

Excel HSTACK function

Excel VSTACK function

Article image

Article image

Article image

Two-way summary count with an excel table

All in one formula with new dynamic array functions