Problem: Why doesn't the subtotal feature offer Median?
Strategy: In Excel 2010, Microsoft added a new function called AGGREGATE. The AGGREGATE function is SUBTOTALS's stronger cousin. The function offers the same 11 calculation options plus several new ones.
- Aggregate offers more calculation options.
The options argument offers more choices for which rows are included.
- More options for what to ignore.
The AGGREGATE function offers potential for some incredible calculations. The new calculation arguments of 12 through 19 allow for array formulas, which would lead to some good additions for the Excel Gurus Gone Wild book. But to solve the median problem, it requires a simple Find and Replace.
To use a MEDIAN in a subtotal, you can use the Subtotal command to sum the column in question.
Select the column. Use Find and Replace. Find SUBTOTAL(9, and replace with AGGREGATE(12,0,.
- Change subtotals to medians.
Additional Details: If you are interested in Medians, you might also want to create a Median in a pivot table. The Power Pivot add-in for Excel 2015 will finally allow medians in pivot tables. As I write this, the feature is in beta, but as you read this, it might be available.Horizontal Subtotals
Problem: Why doesn't Excel offer horizontal subtotals?
- Add a subtotal in E for Q1.
Strategy: This is a great question. In my podcast episode 1001, I had several people write in to say that they regularly used this method to add horizontal subtotals. Although it is a lot of steps, if you use shortcut keys, it is actually fast.
- Select the original data with Ctrl+*
- Go a few rows below the data. Paste with Alt+E+S+E+Enter.
- Alt+D+B to display the Subtotals dialog. Click OK.
- Ctrl+C to copy the vertical data set with the subtotals.
- Select cell A1.
- Paste Transpose with Alt+E+S+E+Enter.
- Fix the column widths with Alt+O+C+A.
- Horizontal subtotals.
- Delete the temporary table at the bottom.
- Optionally, select columns B:D and choose Data, Group.
- Select columns F:H and press F4 to re-do the group command.
- Repeat step 10 for J:L and N:P.
- Select B:Q and choose Data, Group.
You now have collapsible horizontal subtotals.
- After manually adding groups.