+ Reply to Thread
Results 1 to 8 of 8

Pivot table- How does excel calculate the average of a column sliced by another column?

  1. #1
    Registered User
    Join Date
    08-26-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    26

    Pivot table- How does excel calculate the average of a column sliced by another column?

    Hi there, I am learning the kaggle tutorial on learning patterns from data regarding the sinking of the titanic:

    One method is using pivot tables, but, I don't understand the math excel is using! Please could some help explain the calculation. Thank you!


    There are 891 rows of data, each row for a passenger.

    There are several columns which have data regarding this passengers. One column is "survived", which has binary data, 0 representing not survived, and 1 = survived.

    342 of these passengers survived. In a pivot table, this would put the Average of survived as 0.38383838 etc .
    I understand this calculation, because it is simply 342(number of survivors) divided by 891 (number of passengers) No problem!



    However, the calculation I do not understand is when I introduce another column into the row labels in the pivot.

    This new column is the gender of the passengers. Now, the pivot table breaks down the Average of Survived by female and male. But I don't understand the calculation.


    Row Labels Average of Survived Sum of Survived count of gender
    female 0.742038217 233 314
    male 0.188908146 109 577
    Grand Total 0.383838384 342 891


    I don't understand this, there is no missing data, but the average of survived for female (0.742038217) and male (0.188908146) do not add up me? There were 233 women, and 342 survivors, so the percentage of women who survived would be about 68%?

    Essentially what I don't understand is the difference between the the percentage of women who survived, and the average of women who survived. How does Excel come up with this figure of 0.742038217 for women and 0.188908146 for men?

    Sorry I cant upload the excel spreadsheet as I am unable to from my work computer. But the link to the CSV file if needed is https://www.kaggle.com/c/titanic/data (it is the csv file called train)

    Thank you for your help!
    Last edited by trenzalore888; 04-07-2017 at 06:58 AM.

  2. #2
    Registered User
    Join Date
    08-26-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    26

    Re: Pivot table- How does excel calculate the average of a column sliced by another column

    Sorry I messed up! I have now included the Count of gender, (314 females, 577 males)

    I can now see excel has calculated
    Female average survived: 233/314 = 0.742038217
    male average survived: 109/577=0.188908146

    But I still find it weird it doesn't add up to 100%?

  3. #3
    Registered User
    Join Date
    08-26-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    26

    Re: Pivot table- How does excel calculate the average of a column sliced by another column

    Ok I nearly understand it! so it is because I have not taken into account the not survived women and the not survived men.

    not survived women = 81 (91/314 = 0.257961783 , which plus 0.742038217 = 1

    not survived men = 468 (468/577)= 0.81109186, which plus 0.188908146 = 1


    My only question now though is how can you create this column on the pivot table? I had to manually put this in separate cells. When you drag the "survived" column to values, the sum of survived automatically takes those who survived, is there a way to pull it into the values to show as not survived??

    Thank you

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Pivot table- How does excel calculate the average of a column sliced by another column

    Are you able to upload the csv file here.

    Kaggle is wanting me to sign up to its service
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Registered User
    Join Date
    08-26-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    26

    Re: Pivot table- How does excel calculate the average of a column sliced by another column

    Unfortunately I cannot upload it to this website, but I can upload it to a file host website? Is there one that you can use/recommend and I can upload it there? Thank you


    when I try to upload it here I just get a blank box: upload error.png

  6. #6
    Registered User
    Join Date
    08-26-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    26

    Re: Pivot table- How does excel calculate the average of a column sliced by another column

    Here is a screenshot of my pivot table so far.

    You can see below the pivot table I manually worked out the count of not survived women/men and the average of not survived women/men

    But is there a way to do this within the pivot table? Ie get those yellow highlighted cells into the pivot table pivot table unfinished.png

    thank you

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Pivot table- How does excel calculate the average of a column sliced by another column

    Have you played around with the 'Show Values As % of....' options where you can choose Parent Rows/Columns or Total Rows/Columns.

    What about putting two helper columns in your data for 'Not Survived Men' & Not survived Women' and using these in the PT?

    Are you able to put the file in DropBox and attach a link here?

  8. #8
    Registered User
    Join Date
    08-26-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    26

    Re: Pivot table- How does excel calculate the average of a column sliced by another column

    https://www.dropbox.com/l/s/AABftbDZ...kqTw8V1xKCZdM8

    Does this link work?

    I was hoping to avoid helper columns if possible, I tried using shows values as % of, but couldn't get it to work. I thought difference from would work but no luck. I think the key is to get the new column to be Count of gender minus sum of survived.

    Thanks for your help!
    Last edited by trenzalore888; 04-07-2017 at 08:50 AM.

+ 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. Pivot Table, average of sums in column
    By DeeRok in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 06-08-2014, 01:48 AM
  2. I want to add an average column to a pivot table
    By RobMcG in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 09-12-2013, 07:02 AM
  3. Pivot Table - calculate a new column
    By sztob in forum Excel General
    Replies: 3
    Last Post: 03-13-2010, 04:08 PM
  4. [SOLVED] Pivot Table -- Add column to average Grand Total
    By Lynn in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-06-2005, 05:05 PM
  5. [SOLVED] Pivot Table -- Add column to average Grand Total
    By Lynn in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-30-2005, 11:05 AM

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