Explanation

In this example, we have a list of 100 issues in Columns B to D. Each issue has a date and priority. We are also using the named range dates for C5:C104 and priorities for D5:D105. Starting in column F, we have a summary table that shows a total count per month, followed by a total count per month per priority.

We are using the COUNTIFS function to generate a count. The first column of the summary table (F) is a date for the first of each month in 2015. To generate a total count per month, we need to supply criteria that will isolate all the issues that appear in each month.

Since we have actual dates in column F, we can construct the criteria we need using the date itself, and a second date created with the EDATE function . These two criteria appear inside COUNTIFS like so:

dates,">="&F5,dates,"<"&EDATE(F5,1)

Roughly translated: “dates greater than or equal to the date in F5 and less than the date in F5 plus one month”. This is a convenient way to generate “brackets” for each month based on a single date.

When the formula is copied down column G, COUNTIFS generates the correct count for each month.

Note: if you don’t want to see full dates in column F, just apply the custom date formats “mmm” or “mmmm” to display the month names only.

With Priority

To generate a count by priority, we need to extend criteria. The formula in H5 is:

=COUNTIFS(dates,">="&$F5,dates,"<"&EDATE($F5,1),priorities,H$4)

Here we’ve added an additional criteria, the named range priorities paired with H4 for the criteria itself. In this version of the formula, we get a count by month broken down by the priority, which is picked up directly from the header in row 5. This formula uses both mixed references and absolute references to facilitate copying:

  1. The reference to H4 has the row locked (H$4) so priority doesn’t change as the formula is copied down.
  2. The reference to F5 has the column locked ($F5) so the date doesn’t change as the formula is copied across.
  3. The named ranges dates and priorities are automatically absolute.

Pivot table approach

A pivot table is a good alternative solution to this problem . In general, pivot tables are easier and faster to set up when data is well-structured.

Explanation

In this example, the goal is to return a count for each color that appears in column C, using the color values already in column E as criteria. When working with data, a common need is to perform summary calculations that show total counts in different ways. For example, total counts by category, color, size, status, etc. The COUNTIF function is a good way to generate these kinds of totals. Also included below are links to a pivot table option and a dynamic array formula option. Both of these alternatives can automatically extract the values to count and generate the counts at the same time.

COUNTIF function

The COUNTIF function takes two arguments: a range of cells to count, and the criteria to use for counting. For example, to count cells equal to “red” in a range, we could use COUNTIF like this:

=COUNTIF(range,"red") // count "red" cells

In this example, we want a count for 3 colors, so we have manually created a small table that lists all colors in column E. This allows us to use the color names in column E both for labels, and for the criteria that goes into COUNTIF as the second argument . The formula in cell F5 is:

=COUNTIF(color,E5) // returns 3

where color is a named range for cells C5:C16. As the formula is copied down, it returns a count for each of the three colors shown in column E. Notice because we are testing for equality, we don’t need to use any logical operators in criteria . We can simply use the value in cell E5 directly for criteria .

By default, named ranges behave like absolute references and do not change when copied. This means the reference to color does not change, while the reference to E5 is relative and changes at each new row. Alternately, we could use an absolute reference instead of a named range like this:

=COUNTIF($C$5:$C$16,E5) // absolute address

The formula above will return the same results.

Pivot table solution

If you have a limited number of values to count this is a good solution. However, if you have a large list of values that will change over time, a pivot table is a better option since it will automatically expand to include new data.

Dynamic array formula solution

Now that dynamic array formulas are part of Excel , it is possible to build a dynamic summary count with formulas , including an all-in-one formula. Like a pivot table, a dynamic formula will automatically expand to include new data. Unlike a pivot table, formulas recalculate automatically and do not need to be refreshed.