+ Reply to Thread
Results 1 to 28 of 28

Excel 03 pivot table - working with yes/no and averages

  1. #1
    Registered User
    Join Date
    11-18-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Excel 03 pivot table - working with yes/no and averages

    Hi

    I have a spreadsheet containing a pivot table, the data comes directly from an Access 2003 database.

    The purpose of the table is to summarise informtion which is responses customers have made on evaluations of training courses and events.

    As you can see on the attached screenshot, the table averages the numerical data (i.e. marks out of 4 for each section).

    The problem I have is for a section called 'would you recommend?' - which a delegate would answer yes/no for (it's in yes/no format in the Access database).

    For the life of me I don't know how to average this in the pivot table - what I need/would like is the average %age of people who said 'yes' (would recommend) but I don't know how.
    As you can see on the attached it's currently counting all records, not just 'yes' or 'no'.

    If anyone knows how I can do this I will be hugely grateful as I can then get this project completed.

    Many thanks in advance
    Attached Images Attached Images

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,098

    Re: Excel 03 pivot table - working with yes/no and averages

    Go to Value field settings and change sum to average
    Never use Merged Cells in Excel

  3. #3
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,169

    Re: Excel 03 pivot table - working with yes/no and averages

    so the results in Jan show 8 - thats 8 Yes and Nos - so you need to have returned the number of Yes in Jan
    So in the data set - you could add a extra column that counts the Yes and use that

  4. #4
    Registered User
    Join Date
    11-18-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Excel 03 pivot table - working with yes/no and averages

    Quote Originally Posted by zbor View Post
    Go to Value field settings and change sum to average
    Hi zbor - if I do that I get '#DIV/0!' in each cell

  5. #5
    Registered User
    Join Date
    11-18-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Excel 03 pivot table - working with yes/no and averages

    Quote Originally Posted by etaf View Post
    so the results in Jan show 8 - thats 8 Yes and Nos - so you need to have returned the number of Yes in Jan
    So in the data set - you could add a extra column that counts the Yes and use that
    Hi estaf - thanks - do you mean add something in Access to do so?
    The spreadsheet itself doesn't have the actual data, it's a pivot table directly relating to the Access database

  6. #6
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,169

    Re: Excel 03 pivot table - working with yes/no and averages

    yes, you may need to do that, not sure , or change the pivot so you can count the YES and sum the "would you recommend" so you cabn ivide on by the other

    you may need to add a calculated field to the pivot table
    where
    count Would you recommend = YES
    /
    sum of would you recommend
    gives you the % (x100)

    Then the Total would give you the average

    can you post a sample of the data table - in an excel sheet and the pivot - without secruity issues - maybe blank out any confidential info
    Last edited by etaf; 11-18-2009 at 08:49 AM.

  7. #7
    Registered User
    Join Date
    11-18-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Excel 03 pivot table - working with yes/no and averages

    Thanks etaf - I haven't used calculated fields in Excel before - if you're able to explain how to achieve it that would be superb.
    I've attached an Excel file of the data (although the data itself comes directly from Access)
    and the pivot spreadsheet

    Many thanks
    Attached Files Attached Files

  8. #8
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,169

    Re: Excel 03 pivot table - working with yes/no and averages

    I would probably change the underlaying data within the Access data or query adding extra field, so you can count the number of YES for the would you recommend
    you can then divide by the total number of responses

  9. #9
    Registered User
    Join Date
    11-18-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Excel 03 pivot table - working with yes/no and averages

    Thanks etaf - sorry to be a pain but how would I go about doing that?

  10. #10
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,169

    Re: Excel 03 pivot table - working with yes/no and averages

    i'm sure theres a much easier way to do this (and thought I had done in the past) but cant seem to get it to work for some reason

    I have added a column called "recommend YES" to the data sheet, which is, using if "would you recommend?" is true, then 1 else 0

    then use that field and divide by the total - but to do the total I have to add another column to the data - Count of records - which is a 1 for every record
    this is the bit i dont understand as I'm sure we should be able to just count any field ....

    anyway then add a calculated field
    Recommend YES / count of records

    this will give a % fraction and format for %

    I'm sure we can count the TRUE and divide by records (certain I have done this in past when linked to Access database with a excel spreadsheet for calculating surveys and utilisation before without adding additional columns ) hopefully someonme will answer and point that out

    to see the calc field, click in the pivot table - then on the pivot table toolbar - formuala - clac field
    when it opens it will go to a new field for the calc - click on the field drop down and select the calculated field i have entered
    Attached Files Attached Files
    Last edited by etaf; 11-18-2009 at 11:09 AM.

  11. #11
    Registered User
    Join Date
    11-18-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Excel 03 pivot table - working with yes/no and averages

    Thanks etaf, much appreciated.
    Makes sense - my query now I guess is, given the evaluation will be dynamic (i.e. added to all the time), how can I make the formulas for recommend yes etc automatically go into the new records, other than filling every cell which will make the spreadsheet huge?
    (hope that makes sense!)

  12. #12
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,169

    Re: Excel 03 pivot table - working with yes/no and averages

    can you change the access table to include the columns ?

    How do you query the access database with excel ?

  13. #13
    Registered User
    Join Date
    11-18-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Excel 03 pivot table - working with yes/no and averages

    hi, thanks again

    I don't know a way of changing the access table to have it in.
    The excel was done using data>import external data.

  14. #14
    Registered User
    Join Date
    11-18-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Excel 03 pivot table - working with yes/no and averages

    PS I can't now seem to group (as in the date field) in the spreadsheet?

  15. #15
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,169

    Re: Excel 03 pivot table - working with yes/no and averages

    not going very well......

    is the access db in your control ?

    do you query direct as a PT

  16. #16
    Registered User
    Join Date
    11-18-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Excel 03 pivot table - working with yes/no and averages

    Hi again

    Yes the DB is one I made.
    And yes (currently) Excel imports directly to the pivot table (i.e. you don't see all the actual data on another worksheet etc.)

    thanks

  17. #17
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,169

    Re: Excel 03 pivot table - working with yes/no and averages

    if you own the DB why not do the calc in the DB table for Recommend = Yes and set to 1
    then you can sum that field and divide by the records to get the % when you bring it back to excel

  18. #18
    Registered User
    Join Date
    11-18-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Excel 03 pivot table - working with yes/no and averages

    Hi - at the risk of sounding dense, how would I do that?

    Thanks again, appreciate the help

  19. #19
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,169

    Re: Excel 03 pivot table - working with yes/no and averages

    I dont know how you have your access database structured - but you want to add an extra field to the table you query with Excel
    so in the query that creates that table

    you create a new field "name whatever is appropriate - try to avoid special characters and spaces just use letter and numbers , I use capitals to split names
    ie - WouldRecommendYes

    then use an IIF statement (yep two I's)
    IIf («expr», «truepart», «falsepart»)

    RecommendYES: IIf([Would you recommend?]=True,1,0)

    Now the bit I cant make work, is counting the IDs to get a total number of records to divide by......

    I really dont think this is needed but cannot see at the moment any otherway - hopefully someone else can help here

    Add another field to the query to just add 1 for every record
    RecordCount: 1

    Now you can use in the pivot table
    a calculated field to work out the %

    Sum(RecommendYES) / sum9RecordCount)

    format the field to %

    No because this field is calulated it should provide the correct value what ever you do to the pivot table - for Page filters etc etc

    I have added the DB2, which I created and used with Excel to test and get external data from that DB2

    I used your example data - and added that to the DB2 as a table called Sheet1
    I then have a maketable query called query1 = which creates a table called Test1 - and the query creates the RecommendYes field and the RecordCount field

    Then used the excel to get external data from Test1 table in DB2 via a pivot table, grouped the months and added a calc field for %

    Check the numbers but that should be OK

    Re your first question on averages and percentages

    Be very careful with averaging %

    for example
    IF in Jan 10 records and 1 OK = 10%
    IF in Feb 100 records and 99 OK = 99%
    the total is 100/110 = 90.9%
    but the average of Jan and Feb = 54.5
    Attached Files Attached Files
    Last edited by etaf; 11-19-2009 at 07:05 AM.

  20. #20
    Registered User
    Join Date
    11-18-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Excel 03 pivot table - working with yes/no and averages

    That's great thanks so much.
    I will go over it all this afternoon.
    Really appreciate your help

  21. #21
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,169

    Re: Excel 03 pivot table - working with yes/no and averages

    any questions just come back to here - i will be online most of today UK GMT time...
    I should have sent up email on this forum, so you can email me direct as well

  22. #22
    Registered User
    Join Date
    11-18-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Excel 03 pivot table - working with yes/no and averages

    Cheers - quick question - I notice the 'would your recommend' field in Access is yes/no (as is my original one) but in datasheet view shows as 0/-1 (rather than my original one which it shows as a tickbox - how did you achieve that?

    Thanks

  23. #23
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,169

    Re: Excel 03 pivot table - working with yes/no and averages

    that must have been the way it was imported by Access to show TRUE and FALSE as -1 and 0 on the data but YES/NO on the design

    keep with your old format - you dont want to much changed -

    What do you have in your Table for that field -
    Would you recommend and also the "can we use your comments"

    all that would need changing is the IIF statement to read "YES" instead of TRUE

  24. #24
    Registered User
    Join Date
    11-18-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Excel 03 pivot table - working with yes/no and averages

    OK thanks.
    Right I'm going through it all now so I understand it all.

    When I try and do the pivot from scratch (using the DB you made), it won't let me group by date? Bit confused!
    thanks

  25. #25
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,169

    Re: Excel 03 pivot table - working with yes/no and averages

    mine did group by Date OK
    right click on the EventDate field in grey
    Group and show detail
    Group

    all works just tried again

    If you want to emial me the Access DB and spreadsheet (so its not in a public domain) and your allowed to re secruity / sensitivity of data
    I cna PM my email address

  26. #26
    Registered User
    Join Date
    11-18-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Excel 03 pivot table - working with yes/no and averages

    Ah OK think I've sussed it - it won't let me (using a new xls that is) group if I have the date in page field, but is fine with it if put in the column section.
    I'll crack on this afternoon but (fingers crossed!) think it should be fine, I'll let you know.
    Cheers

  27. #27
    Registered User
    Join Date
    11-18-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Excel 03 pivot table - working with yes/no and averages

    etaf - I've now got it all sorted, just wanted to say many thanks for helping me

  28. #28
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,169

    Re: Excel 03 pivot table - working with yes/no and averages

    your very welcome .... glad to hear that

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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