+ Reply to Thread
Results 1 to 12 of 12

Excel Pivot with Averages

  1. #1
    Registered User
    Join Date
    09-01-2023
    Location
    Portsmouth, OH
    MS-Off Ver
    Office 365
    Posts
    23

    Excel Pivot with Averages

    Excel gurus

    I am working on creating a dashboard for my company. For one of the items of the dashboard I would like to display the number of assessments that occur on each day of the week. Mon thru Saturday). The pivot table is pulling from rows that contain a date that an intake with an assessment has occurred. I have generated an additional column which converts the dates to days of the week. When I drop the day of the week into the column, the pivot table will count the number of days but it will not allow me to generate an average for the day of week. I want to know (based on the number of days I have in my data) what the average number of assessments are for each day of the week without receiving an DIV error (i.e. Monday avg throughout the year 4 assessment per day, Tuesday avg 8 assessment, etc). Please help.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,925

    Re: Excel Pivot with Averages

    A sample workbook will go a long way to solving the issue.

    However, based on the description, I assume you have a helper column that has a formula like =Text([@[Date]],"ddd"). And what you are trying to do is use a count of the day of the week to compute the averages. There is a quirk in pivot tables that reports count as a number but you can't use it in calculations. The solution may be another helper column with the formula =1. Then use this value as a sum by day of the week.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    09-01-2023
    Location
    Portsmouth, OH
    MS-Off Ver
    Office 365
    Posts
    23

    Re: Excel Pivot with Averages

    Thank you dflak, do I just create an adjacent column and literally type =1 ? Do I have to do anything else?

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,925

    Re: Excel Pivot with Averages

    Use this column instead of count of day of the week. If you are still having a problem, post your data. I am guessing in the dark.

  5. #5
    Registered User
    Join Date
    09-01-2023
    Location
    Portsmouth, OH
    MS-Off Ver
    Office 365
    Posts
    23

    Re: Excel Pivot with Averages

    I have attached a word doc which reviews the steps that I've taken. I don't know if I quite understand the helper column calculation '=1' When I type in =1 am I connecting =1 to the cell representing the day of the week? Also when I go to avg the helper column, it only returns back 1's. i have attached a word doc to show my steps.
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,588

    Re: Excel Pivot with Averages

    Please utilize the information in the "HOW TO ATTACH YOUR SAMPLE WORKBOOK" banner at the top of the page to post the .xlsx file from which the screen shots in the .docx file were taken.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  7. #7
    Registered User
    Join Date
    09-01-2023
    Location
    Portsmouth, OH
    MS-Off Ver
    Office 365
    Posts
    23

    Re: Excel Pivot with Averages

    I have attached a sample workbook with deidentified Patient information pertaining to admissions. Please help to present average number of appointment per day of week and by month. I have the pivot table set up to where it shows how many appointments per day of week by month but I am unable to calculate the average per day due to using string data. Please review the attached workbook for additional information.

  8. #8
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,588

    Re: Excel Pivot with Averages

    Perhaps the Excel table and pivot table modeled on Sheet1 will provide the information needed:
    1. Extract the Date, Day and Month columns from the table on the Admissions Long Sheet using Power Query:
    Please Login or Register  to view this content.
    2. Add column D, Count of Appointments, which is populated using: =IF(COUNTIFS(INDEX([Date],1):[@Date],[@Date])=1,COUNTIFS([Date],[@Date]),"")
    3. Add column E, Count of Weekday, which is populated using: =IF(COUNTIFS(INDEX([Date],1):[@Date],[@Date])=1,1,"")
    4. Produce the pivot table with Day of Week in the Rows area and the two added columns in the Values area using the Month column in the Filters area
    5. Add a Calculated Field: ='Count of Appointments'/'Count of Weekday'
    Let us know if you have any questions.

  9. #9
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,925

    Re: Excel Pivot with Averages

    Here is my shot at it. I have two "helper columns"

    One of them is called Unique DOW =1/COUNTIF([Date],[@Date]) - this spreads out the distribution for a date so that when all records with this date are summed they equal 1. In other words when you add up all the Mondays, each Monday in the month contributes 1 to the count.

    The other is One =1

    The average is One / Unique DOW (total appointments / number of that day of the week)

  10. #10
    Registered User
    Join Date
    09-01-2023
    Location
    Portsmouth, OH
    MS-Off Ver
    Office 365
    Posts
    23

    Re: Excel Pivot with Averages

    Alight, I have completed the power query with the two helper columns you referenced. I am still unsure how to go about creating the sum of unique dow as a field option for the pivot.


    Attachment 845343

  11. #11
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,925

    Re: Excel Pivot with Averages

    We need two numbers: the total number of records for dates associated with Mondays and the number of Mondays in the month.

    Gathering the total number of records associated with the Mondays in a month is straightforward.

    We need trick Excel into getting the number of Mondays in the month.

    For example: suppose there are four Mondays in a month and the first one has one record and the second two records and the third three records and the fourth four records.

    Unique DOW =1/COUNTIF([Date],[@Date])

    For the 1st Monday this is 1/1 = 1 and there is only one record with the date so when the figure is summed up it equals 1.

    For the 2nd Monday this is 1/2 = 0.5 and there are two records with this date so when the figure is summed up it equals 1

    For the 3rd Monday this is 1/3 = 0.333 and there are three records with this date so when the figure is summed up it equals 1

    For the 4th Monday this is 1/4 = 0.25 and there are 4 records with this date so when the figure is summed up it equals 1

    The sum of all these figures is 4 which is the number of Mondays in the month.

    A calculated field yields the average.

  12. #12
    Registered User
    Join Date
    09-01-2023
    Location
    Portsmouth, OH
    MS-Off Ver
    Office 365
    Posts
    23

    Re: Excel Pivot with Averages

    Thank you so much dflak! Your instructions were super helpful and easy to follow.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 03-19-2021, 03:06 PM
  2. Replies: 1
    Last Post: 09-11-2019, 03:07 AM
  3. Replies: 4
    Last Post: 03-13-2015, 05:34 AM
  4. Replies: 9
    Last Post: 05-15-2014, 01:57 PM
  5. Calculate orders past agreed dates in pivot table and averages in pivot tables
    By applesandpears in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 10-18-2012, 05:26 PM
  6. Replies: 27
    Last Post: 11-19-2009, 11:50 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1