+ Reply to Thread
Results 1 to 16 of 16

Count of Yes/No in Pivot Table

  1. #1
    Registered User
    Join Date
    05-18-2016
    Location
    Cork
    MS-Off Ver
    2019
    Posts
    78

    Count of Yes/No in Pivot Table

    I want to create a pivot table and do a count of the number of yes and no for each product group. My aim is then to calculate the percentage of the No for each product group based on the yes. Any help would be appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,210

    Re: Count of Yes/No in Pivot Table

    The biggest help would be to have the yes and no in the same column if you wanted to use a pivot table
    in e2 put
    =IF([@No]="",[@Yes],[@No])


    then pivot on this field, but the example contains no values of stock when cateogy is no

  3. #3
    Registered User
    Join Date
    05-18-2016
    Location
    Cork
    MS-Off Ver
    2019
    Posts
    78

    Re: Count of Yes/No in Pivot Table

    That's why I have used the Yes, No, where the stock is zero. But I need to count the zeros. I want then do a calculation to find the percentage the nos (or zero) are of the Yes where there are stock (if that makes sense).

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: Count of Yes/No in Pivot Table

    I used Power Query to achieve the following results. Here is the Mcode.

    Please Login or Register  to view this content.
    Excel 2016 (Windows) 32 bit
    F
    G
    H
    I
    14
    Product sum Yes sum No Pct No
    15
    Product1
    1
    0
    0
    16
    Product2
    2
    0
    0
    17
    Product3
    5
    3
    0.375
    18
    Product4
    5
    2
    0.285714286
    19
    Product5
    5
    1
    0.166666667
    20
    Product6
    4
    3
    0.428571429
    21
    Product7
    5
    0
    0
    22
    Product8
    3
    1
    0.25
    23
    Product9
    2
    0
    0
    Sheet: Sheet1



    Review PQ
    In the attached file
    Click on any cell in the new table
    On the Data Tab, click on Queries & Connections
    In the right window, double click to open Query
    Review PQ steps

    M-code basics:
    - "let" is the start of a query
    - "in" is the closing of a query
    - each transformation step sits in between those 2 lines
    - each step line is ended by a comma, except the last one
    - "Source" is always the first step (Source Data)
    - After "in" you have the last step referenced
    Attached Files Attached Files
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Registered User
    Join Date
    05-18-2016
    Location
    Cork
    MS-Off Ver
    2019
    Posts
    78

    Re: Count of Yes/No in Pivot Table

    Alan, thanks. I have not used Power Query before, but I'll follow your instructions.

  6. #6
    Registered User
    Join Date
    05-18-2016
    Location
    Cork
    MS-Off Ver
    2019
    Posts
    78

    Re: Count of Yes/No in Pivot Table

    Sorry Alan, how do I create a new PQ on the data in my original attached spreadsheet? I have never used PQ before.

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: Count of Yes/No in Pivot Table

    Check out the links in my signature block -- that will be the best way to get started. Then if you are interested in learning more, get a copy of the book "M is for (Data) Monkey" by Ken Puls and Miguel Escobar. It will open lots of new worlds for you.

    Alan

  8. #8
    Registered User
    Join Date
    05-18-2016
    Location
    Cork
    MS-Off Ver
    2019
    Posts
    78

    Re: Count of Yes/No in Pivot Table

    Thanks Alan, appreciate that. I can see how it would be useful. In the meantime, is it possible to do what I want in a simple Pivot Table with adding countif?

  9. #9
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: Count of Yes/No in Pivot Table

    I can't. Maybe someone else is able. I will put in a call to others for help.

  10. #10
    Registered User
    Join Date
    05-18-2016
    Location
    Cork
    MS-Off Ver
    2019
    Posts
    78

    Re: Count of Yes/No in Pivot Table

    Thank you Alan. I appreciate your help.

  11. #11
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,908

    Re: Count of Yes/No in Pivot Table

    If you change the YES and NO to just 1, you can then sum them as counters.
    Rory

  12. #12
    Registered User
    Join Date
    05-18-2016
    Location
    Cork
    MS-Off Ver
    2019
    Posts
    78

    Re: Count of Yes/No in Pivot Table

    Rory, thanks for responding. I have attached revised workbook. I have added 1 for Yes and No columns as advised. I have added a pivot table, but am not getting what I expected. Any help would be appreciated.
    Attached Files Attached Files
    Last edited by phynds; 06-17-2020 at 05:49 AM. Reason: omitted attachment

  13. #13
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,908

    Re: Count of Yes/No in Pivot Table

    What do you expect? I think it would help if you added a mock up table of the results you actually want.

  14. #14
    Registered User
    Join Date
    05-18-2016
    Location
    Cork
    MS-Off Ver
    2019
    Posts
    78

    Re: Count of Yes/No in Pivot Table

    Sorry Rory, I thought it was giving me an incorrect number of yes, but it is correct. I think this will work ok. I'm going to test it on my original data now. Really appreciate your help.

  15. #15
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,908

    Re: Count of Yes/No in Pivot Table

    No worries. Just post back if you have any problems with it.

  16. #16
    Registered User
    Join Date
    05-18-2016
    Location
    Cork
    MS-Off Ver
    2019
    Posts
    78

    Re: Count of Yes/No in Pivot Table

    Thanks to everyone for their help. All sorted. How or where do I mark this as solved?

+ 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: 1
    Last Post: 05-16-2014, 07:34 PM
  2. How to count distinct values from table in pivot table
    By gopijadhav in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 01-04-2014, 07:14 AM
  3. [SOLVED] Count in Pivot Table
    By sarinky in forum Excel General
    Replies: 3
    Last Post: 05-08-2012, 06:23 AM
  4. Replies: 2
    Last Post: 02-11-2012, 09:33 PM
  5. Count without using pivot table
    By Tony Vargo in forum Excel General
    Replies: 2
    Last Post: 09-28-2011, 12:50 PM
  6. pivot table count if
    By spinkung in forum Excel General
    Replies: 1
    Last Post: 10-31-2009, 06:11 AM
  7. Pivot table count
    By matpj in forum Excel General
    Replies: 2
    Last Post: 03-25-2008, 08:23 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