# How to Calculate Daily Averages with a Pivot Table

Bottom line: Learn how to calculate the average of a daily total amount across month, quarters, years, or even categories with a pivot table.

Skill level: Intermediate

## Video Tutorial

You can download the Excel files below.  The BEFORE file just contains the source data, and can be used to follow along with the video.  The AFTER video contains the solution and sample pivot tables.

## Average of Total Daily Sales

Kevin, a member of The Pivot Ready Course, asked a great question about calculating the average of total daily sales in a pivot table.

In this case his data set contained a sales transaction in each row.  There are multiple sales per day, so the dates will repeat in the Date column.

If we use the regular Average calcluation type in the pivot table, the result will be the average amount per transaction.  This is NOT what we want.

Instead, we want to see the average daily total across a larger time period like months quarters or years.

## Why Analyze Daily Averages?

The daily average metric can be useful in comparing trends for daily totals across time period (months, quarters, etc.) or even categories (regions, departments, days of the week, etc.)

We can use a line chart or column chart to quickly see how the daily average changes over time.

## How the Calculation Works

IMPORTANT NOTE: You will need Excel 2013 or later for Windows for this method.  This includes Office 365.  Unfortunately, this will not work on Excel 2010, or the Mac versions of Excel.

This technique uses DAX measures in the Power Pivot Data Model.   We are going to use the DISTINCTCOUNT function to calculate the unique number of days in the data set.  DISTINCTCOUNT is a DAX function in Power Pivot.

We then divide Total Sales by the Distinct Day Count to get the Average of Total Daily Sales.  This can be any amount (numeric value).  It does NOT have to be sales data.

`[Average of Total Daily Sales] = [Total Sales]/[Distinct Day Count]`

Here are the steps to creating the pivot table and measures.

### Step 1: Insert a Pivot Table & Add to Data Model

The first step is to insert a pivot table from your data set.

Important: Click the “Add this data to the Data Model” checkbox on the Create PivotTable Window.

This will add the data to Power Pivot and allow us to write DAX measures for the Distinct Count calculation.

### Step 2: Create the DAX Measures

Next we need to create the measures.  We are going to create explicit measures for three calculations:

1. Total Sales = SUM([Amount])
2. Distinct Day Count = DISTINCTCOUNT([Date])
3. Daily Average = [Total Sales]/[Distinct Day Count]

To create a measure:

1. Right-click the Table name in the Pivot Table Fields List.
2. Select Add Measure.  The Measure Window will appear
3. In the Measure Name box type: Total Sales
4. In the Formula box type: =SUM([Amount])
5. Click OK.

The measure will be created and added to the bottom of the Fields List.  Repeat the steps above for the other two measures.

#### Implicit vs Explicit Measures

For the first two formulas we could also create the calculations by dragging the Amount and Date fields into the Values area, then changing the calculation type as need.  These are know as implicit measures when we use Excel to create the measure by dragging and dropping fields.

The other option is to write the formulas in the Measure window, like we did above.  These are known as explicit measures because we clearly explained or defined them in the formula editor.

One advantage of the explicit measures is that we can continue to use them in other formulas or pivot tables.  Now that we have defined the Total Sales measure, it will be available in all new pivot tables from the data model.

We can also re-use the Total Sales measure, as we did in the Daily Average measure, and continue to build more complex formulas with it.  This saves time and makes formula writing more efficient in the long run.

There are also advantages when using Power BI and bringing the data model back into Excel.  My friend Avi shows an example in this video where Implicit measures are not imported to Excel from Power BI.

### Step 3: Add the Measures to the Pivot Table

The next step is to add the measure fields to the Values area of the pivot table.

You do NOT need to add all of the measure fields to the pivot table.  The calculations will still work even if you only add the Daily Average field to the Values area.

However, the Total Sales and Distinct Day Count fields can be a nice addition to the pivot table.  They might help show additional trends or explain why a daily average is high/low for a specific period.

The same measures will also work in Power BI, since Power BI uses Power Pivot to create relationships and measures.  Checkout my course on Dashboards & Data with Power BI to learn more.

### Step 4: Create Date or Category Groupings

We now need to add fields to the Rows and/or Columns Areas to create the trend report.

For this example, we will add the Date field to the Rows area and Group it by Year, Quarter, and Month.

Checkout my article on Grouping Dates in a Pivot Table VERSUS Grouping Dates in the Source Data to learn more about date grouping.

I also have an article on The Calendar Table (Date Dimension) Explained for Power Pivot & Power BI.  Calendar tables allow us to create relationships between different data sources.  They can also be used if your company is on a fiscal calendar.

#### Make Sure Subtotals are Turned On

If you don't see numbers for the Year, Quarter, or Month lines, then the Subtotals are turned off in your pivot table.  Here is a screenshot that shows how to turn the subtotals on.

To turn the Subtotals on in a pivot table:

1. Select a cell inside the pivot table.
2. Select the Design tab in the ribbon.
3. On the Subtotals drop-down menu, select “Show all Subtotals at Bottom of Group” or “Show all Subtotals at Bottom of Group”.
4. You should now see the subtotal calculations for the row area groupings (year, quarter, month).

Finally we can add a quick pivot chart to analyze the trends of the daily averages.  Here is a line chart that compares the Average Daily Sales by Month and Region.

We can see that the North region did better than the South in the last two months of the year.  And the South had a declining trend after March.

## What Do You Use Daily Averages For?

So, that is one way to calculate daily averages with pivot tables using Power Pivot and DAX Measures.  DAX measures are amazingly powerful, and this simple example only scratches the surface of their capabilities.

I'd love to know what you use daily average metrics for.  Please leave a comment below and let us know.  Thanks so much! ðŸ™‚

## Free Training Webinar on the Power Tools

If you are currently using pivot tables, but feel like you aren't getting the most out of them, then I have a free training just for you.

Right now I'm running a free training webinar on all of the Power Tools in Excel. This includes Power Query, Power Pivot, Power BI, pivot tables, macros & VBA, and more.

It's called The Modern Excel Blueprint. During the webinar I explain what these tools are and how they can fit into your workflow.

You will also learn how to become the Excel Hero of your organization, that go-to gal or guy that everyone relies on for Excel help and fun projects.

The webinar is running at multiple days and times. Please click the link below to get registered and save your seat.

• Pernille says:

Thanks so much for the post.Really thank you! Great.

• SteveT says:

Jon,
I was looking at just such a problem today. Lots of numbers for individual groups, but the user wanted the average for each user, to see who was slacking in finishing a particular report. A pivot table didn’t quite do the job, and I knew I’d need a formula, so was going to try with Power Query tonight; but I think I’ll give your approach first dibs!

Thank you!

SteveT

• Hi SteveT,
That’s awesome! It sounds like you might be able to adapt this technique to find the average for each user. A lot depends on the structure of the data. It might make for an interesting example. If you want to send an sample file I’d be happy to take a look and see if it might make a good topic for another post. You can reply to the newsletter email and attach the file, if you want.

Thanks again! ðŸ™‚

• I have the same request from my business, and I’m not sure how to adapt this to solve it… If I do “DistinctCount”, then it’s pulling a number for the whole team, but I need to do a distinctcount for each user (omitting days the team member may have taken PTO, etc.). I’m trying to determine the average per week, and my data set lists (by row) what issue the user was able to resolve and the date it was resolved. (It includes much more info, but this is the gist.)
So far, I’ve pulled a Pivot Table of each user and how many issues they’ve resolved each week split out by complexity of the issue they’ve resolved. There’s a grand total, which I use to manually figure the average per week per user.

I’ll keep playing with this “add measure” thing… It certainly seems promising! I’m just not sure how to get it to do this for each user as well as by complexity of issue.

• Analog says:

V nice, thanks

• Puyu says:

Great tutorial
Thanx Jon

• Haley says:

another great tutorial Excel Lord !

• Mo says:

Thanks Jon. Really enjoyed the post.
When I added the grouped day/month/year fields to my Rows, they did not appear with the values for Total Sales, Day Count, Daily Average as they do in your vid. Is this a setting somewhere?

• Hi Mo,

You might have to manually drag each field into the Rows area after grouping them. I believe this behavior depends on which version of Excel you are on.

I hope that helps.

• veda says:

Hi Jon,

I am using Excel 2013. I don’t see add measures when I right click on my table in pivot table. I had to go to power pivot and use calculated fields to achieve the same. Also I am not able to drill down on date. It tells drill down not possible here. Group option is also disabled.

• Hi Veda,

Yes, in Excel 2013 you can add the Measures from the Power Pivot tab in the ribbon. This is different from a calculated field. You will also want to make sure the source data is added to the data model, then create the pivot table from the Power Pivot window or from the Insert tab.

Here’s an article that explains Why the Pivot Table Group Field Button is Disabled for Dates.

I hope that helps. Thanks again and have a nice day! ðŸ™‚

• Alice Coston says:

Is the free webinar eligible for CPE?

• Hi Alice,
The webinar is not eligible for CPE at this time. Thanks!

• Edil says:

Thx Jon. Awesome!

• Bill vonZangenberg says:

Great video and explanations.

• Shankhajit says:

Hi Jon – hope you are doing fine ! I am not sure how to get about a particular scenario, so if you could please help me out I would be obliged. Is it possible to create a pivot table based on data in multiple worksheets and grouped by a composite field structure – eg. I have 4 sheets A, B, C, D each having Year and Month column plus some additional data columns (one is say ‘K’) (year and month have repeating rows)…now I want to consolidate (pivot / aggregate) all this data on a separate sheet grouped by Year, Month (rowwise) and K should be a filter and columns should be the name of sheets – A,B,C,D. waiting for your response.

Rgrds
Shankhajit

• Free auto approve list 8-9-2018 says:

Iâ€™ve been having issues with my Windows hosting. It has set me back quite a bit while making the next list. This is the current list that I have. I should add another list in less than a week. Iâ€™ll let you all know when the next list is ready. Thank you for your patience.

• Qian says:

I cannot find distinct count in my pivot table calculation.

• Kayda says:

Hi there,
I have an excel spreadsheet which I think would benefit from this, but I’m not exactly sure how to use it. Here’s some example data:
Agent Policy Number V1 Mileage V2 Mileage V3 Mileage
A RB1111 10300 9000 2000
A RB2222 13000 5000 13000
A RB3333 12000 11000 10000
B RA1111 12500
B RA2222 7200 8000 8900
B RA3333 1500 3000
C RC1111 2000 9000 5000
C RC2222 9100 7000 12000

In this example, I want to Average Agent A’s mileage for all 3 columns (so it’s not just an average per policy number, but an average for all policies and mileage together).

I can easily pivot the averages for A, B and C, but it isn’t combined for ALL 3. Can you assist?
Thanks!
Kayda

• Carmella Sahl says:

Together with everything that seems to be developing within this subject matter, many of your opinions are actually relatively radical. However, I am sorry, but I can not subscribe to your whole strategy, all be it refreshing none the less. It seems to me that your remarks are not entirely rationalized and in actuality you are yourself not really entirely certain of your assertion. In any event I did enjoy examining it.

• Es says:

Hi,
Nice tutorial but he results are not as expected in my case. I would like to have the daily average for every day of a certain month but I do not have sales for every day of the month(some day 2 some days none). Therefor I have missing dates and the calculation: “amount / days of the month” (which returns the actual daily average if I’m right) does return something completely else then the pivot table from this tutorial returns.

Am I missing something?
Thanks Es.

• Ashish says:

Thanks Jon.. It was awesome.. I was able to clear my doubts..

• Tommy Wilson says:

Jon I tried this Daily Average Data Model and when I right click on the table i don’t get an option to add a measure. Only option is to remove the table. I’m running windows excel 2013 on Windows 7 pro. Is there a step I’m missing?
From your AFTER worksheet I do see the measures you created as calculated fields.

I have an application where I believe this will come in very handy and I want to understand how to make it work.

• Emile says:

Great video!

I have one question… when i get to the step of adding the Distinct formula it works but when i go to drag it i get an error message (A table of multiple values was supplied where a single value was expected).
This could be due to the fact that I used a “int” formula to separate the date from my official “Date & time” column.

Do you know any workarounds, it would be greatly appreciated.

Thank you

• Rupesh says:

Jon
This video really helped me a lot. It’s 3 PM here in India and I got my doubts cleared. I’m recommending this video to everyone who ever is facing such issues. Thanks again.

• zaine says:

Thank you sir! I complete videos series of “Excel Pivot Tables” which really helpful. sir kindly add excel vba playlist also. God bless you.

• Neil says:

Brilliant – thanks

• Eva says:

Hi! In my case, I should take the average of the distinct count column. Is it possible to do that in the pivot table?

• rob says:

Hi,

thank you SO much for this. I used this article to set up a calculation of a daily average of inbound calls per hour of day per day of week of month so that I can build a forecasting model. Sounds convoluted, but it works! It gives me an average of number of calls on, say, first Tuesday of the second week of the month between 9 and 10 o’clock.

Took a bit of finagling, but the base is sound and the calculation works!

• Michael says:

Thanks, it’s very clear!

Can you advise if I would like to have median instead of average, how can I go about it?

• Thank you says:

Thank you so much for these instructions, Jon. They made such a difference in what I was able to analyze!

Generic filters
Exact matches only

#### Excel Shortcuts List

Learn over 270 Excel keyboard & mouse shortcuts for Windows & Mac.

Excel Shortcuts List