How to Calculate Median in an Excel PivotTable – Almost!

A frequent question that comes up when working with Excel PivotTables is how to calculate median using the table’s filters and analysis. The short answer is “Excel doesn’t do that”. Meaning, there isn’t a simple way to change the Value Field Settings to calculate “Median”. The closest you can get is “Average”.

However, averages aren’t always the best way to understand your data. Our example shows donations collected by a regional charity. Most of the donations are small amounts, a handful are more significant, and one or two are very large. The average donation for the year is \$1380.50, but that does not accurately show us how most of our donors give. The median calculation shows us that most of our donations are around \$50 with half giving more, and half giving less. This number more realistically reveals our donor giving patterns.

If we want to understand our donor giving patterns by state, we would naturally turn to a PivotTable and get something like we see in the first image. But what if we want the median donation for each state?

Here is the first of two “workaround” solutions to get a median calculation out of your PivotTable information. As with all workarounds, it may not be elegant, but it can get you started. The steps demonstrated will apply to Excel 2010 and later.

Use the Array Feature

Technically, the end result isn’t a PivotTable, but you can use the PivotTable feature to set up your array more easily:

1. First, create a PivotTable with the data organized in the way you want except with an Average calculation instead of Median in the Values area.

2. Then, select the PivotTable cells (headings included) and hit Ctrl+C to copy the table to your clipboard.

3. Right-click on an open cell and select Paste Special > Paste Values to paste a copy of the table’s headers and values in your worksheet.

4. Add a column to the new table for the Median calculation.

5. For each Row Label, combine the IF function with the MEDIAN function to pull only the data that corresponds to the fields in the PivotTable. Type the formula in the Median column. In our example, the formula will look like:

=MEDIAN(IF(\$H\$2:\$H\$65=J19, \$C\$2:\$C\$65))

To break down the formula:

• =MEDIAN( tells Excel to calculate the median of the numbers that the IF statement returns
• IF((\$H\$2:\$H\$65=J19, tells Excel to only return donor amount values if the value in the H column – State – matches the value in the J column (our PivotTable State Row Label). Use the \$ symbol to specify absolute cell values.
• \$C\$2:\$C\$65)) tells Excel to return the values in the C column that meet the above criteria for the MEDIAN function. Use the \$ symbol to specify absolute cell values.
• Hit Ctrl+Shift+Enter Important! Don’t just hit enter to complete the formula. You must hold Ctrl+Shift+Enter down together to complete the formula and tell Excel that it is an array formula. Excel will add curly braces around the formula if this is done correctly:

6. Now you can drag the formula to the other cells in the “fake” PivotTable and quickly see the Median Donation for all States covered by the charity.

So, “this isn’t really a PivotTable”, but this method does allow you to quickly harness the visual power of PivotTables to organize your information. You still have to do the manual work of making the Median calculation, but the PivotTable step gives you a shortcut to organizing your information and creating the formula. And until Microsoft adds the MEDIAN function directly to PivotTables, this is the most common solution out there.

Microsoft® Excel® Basics

LIVE ONLINE SEMINARS

May. 11

Central Time Zone

May. 13

Eastern Time Zone

May. 18

Central Time Zone

May. 20

Pacific Time Zone

May. 24

Eastern Time Zone

May. 26

Central Time Zone

Jun. 2

Central Time Zone

Jun. 8

Eastern Time Zone

Jun. 10

Central Time Zone

Jun. 14

Central Time Zone

Jun. 16

Pacific Time Zone

Jun. 22

Central Time Zone

Jun. 24

Eastern Time Zone

Jun. 28

Central Time Zone

Jul. 7

Eastern Time Zone

Jul. 8

Central Time Zone

Jul. 12

Central Time Zone

Jul. 14

Pacific Time Zone

Jul. 15

Eastern Time Zone

Jul. 20

Eastern Time Zone

Jul. 20

Pacific Time Zone

Jul. 21

Central Time Zone

Jul. 26

Pacific Time Zone

Jul. 27

Central Time Zone

Aug. 4

Pacific Time Zone

Aug. 5

Central Time Zone

Aug. 9

Central Time Zone

Aug. 10

Eastern Time Zone

Aug. 11

Central Time Zone

Aug. 17

Eastern Time Zone

Aug. 19

Central Time Zone

Aug. 23

Central Time Zone

Aug. 25

Central Time Zone

Aug. 26

Pacific Time Zone

Aug. 30

Central Time Zone

Aug. 31

Eastern Time Zone

Microsoft® Excel®: Beyond the Basics

LIVE ONLINE SEMINARS

May. 12

Central Time Zone

May. 14

Eastern Time Zone

May. 19

Central Time Zone

May. 21

Pacific Time Zone

May. 25

Eastern Time Zone

May. 27

Central Time Zone

Jun. 3

Central Time Zone

Jun. 9

Eastern Time Zone

Jun. 11

Central Time Zone

Jun. 15

Central Time Zone

Jun. 17

Pacific Time Zone

Jun. 23

Central Time Zone

Jun. 25

Eastern Time Zone

Jun. 29

Central Time Zone

Jul. 8

Eastern Time Zone

Jul. 9

Central Time Zone

Jul. 13

Central Time Zone

Jul. 15

Pacific Time Zone

Jul. 16

Eastern Time Zone

Jul. 21

Eastern Time Zone

Jul. 21

Pacific Time Zone

Jul. 22

Central Time Zone

Jul. 27

Pacific Time Zone

Jul. 28

Central Time Zone

Aug. 5

Pacific Time Zone

Aug. 6

Central Time Zone

Aug. 10

Central Time Zone

Aug. 11

Eastern Time Zone

Aug. 12

Central Time Zone

Aug. 18

Eastern Time Zone

Aug. 20

Central Time Zone

Aug. 24

Central Time Zone

Aug. 26

Central Time Zone

Aug. 27

Pacific Time Zone

Aug. 31

Central Time Zone

Sep. 1

Central Time Zone

Advanced Microsoft® Excel®-Macros, PivotTables, Charts and More

LIVE ONLINE SEMINARS

May. 6

Central Time Zone

May. 14

Central Time Zone

May. 19

Eastern Time Zone

May. 25

Central Time Zone

Aug. 3

Central Time Zone

Aug. 4

Eastern Time Zone

Aug. 12

Central Time Zone

Aug. 17

Central Time Zone

Aug. 23

Central Time Zone

Sep. 1

Pacific Time Zone