The mention of the subtotal formula will probably cause you to relate the formula to calculating the total for sub-groups of data. This is generally true. But the formula can also be used to calculate average, count numbers, count text and number, find maximum, find minimum, addition and 5 other types of calculation. That was what our participants in "Hidden Secrets in Data Analysis with Excel" found out. Neither do they think they should be trained in this formula or realised how powerful it can become when it is combined with the auto-filter function.

Let me share with you what is this formula and how it works.

Subtotal formula requires 2 basic inputs, the function number and a range.

The function number determines the type of calculation to be performed with the formula. If the function number 1 is used, it calculates the average of the numbers found in the range listed. If the function number is 2, it is used to count numbers. See below for the complete list of calculations you can do with formula.

Function Number | Function | Meaning |

1 | AVERAGE | Average value for the filtered range |

2 | COUNT | Count the number of cells that contain values in the filtered range |

3 | COUNTA | Count the number of non-blanks cells in the filtered range |

4 | MAX | Returns the max value in the filtered range |

5 | MIN | Returns the min value in the filtered range |

6 | PRODUCT | Multiplies the values in the filtered range |

7 | STDEV | Returns the standard deviation for the sample in the filtered range |

8 | STDEVP | Returns the standard deviation for the population in the filtered range |

9 | SUM | Returns the sum of all the values in the filtered range |

10 | VAR | Returns the variance for the sample in the filtered range |

11 | VARP | Returns the variance for the population in the filtered range |

The range defines the cells that should be involved in the calculation. This is usually entered as one continuous range. But it doesn't have to be limited to one continuous range. You can list multiple ranges in the formula.

From the above explanation, you probably think that it is a good substitute for the SUM, COUNT, COUNTA, AVERAGE formulas. That is true if you are using it in isolation. But if you use the Subtotal formula together with Auto-filter, it will calculate the results based on the filtered rows only. Hidden rows are excluded from the calculation even though the range is included in the formula.

For example, in a list of 20 items, the Subtotal formula will return 20 as the answer. The COUNTA formula will also return the result as 20. But if you filter the list based on a certain criteria, some of the rows are hidden. If you look at the Subtotal formula again, you will find that it counts the number of rows that are visible to you. As for the COUNTA formula, it continues to show the number 20.

Learn about the SUBTOTAL function.

•

## New! Comments

Have your say about what you just read! Leave me a comment in the box below.