+ Reply to Thread
Results 1 to 22 of 22

Pivot Table - Count data From Multiple Columns

  1. #1
    Registered User
    Join Date
    02-09-2011
    Location
    Durban, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    23

    Smile Pivot Table - Count data From Multiple Columns

    Hi,

    Need to take 'count' of data from multiple columns and show on Pivot Table

    Hi All,

    Have a spreadsheet that looks as follows:

    Battery No : Battery No : Battery No

    5 : 8 : 1
    3 : 9 : 5
    1 : 5 : 3

    Need data to be displayed on a pivot table with count of number of times each number appears
    eg. Total of 5 = 3 times; Total of 3 = 2 times etc.

    Got it to work for 1 column but when I use multiple columns, total is of individual columns rather than a collective count for each piece of data.
    Would like pivot to show data from all "Battery No" Columns to reflect as a column and the corresponding "Cumulative Count" to show in adjacent row

    Thanks - PS: Fairly Illiterate in Excel
    Last edited by Ashraf1; 02-23-2011 at 08:20 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Pivot Table - Count data From Multiple Columns

    For a Pivot you would need to transpose your data set first I'm afraid.

    If your data is really numeric you could use the set as is by using formulae to generate the frequency table

    Assume your matrix is A1:C4 (headers row 1) then:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-09-2011
    Location
    Durban, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Pivot Table - Count data From Multiple Columns

    Thank You,

    To be quite honest, I have no idea what you talking about. Is there anyway you could explain this in simpler terms or could I perhaps attach the spreadsheet and you edit accordingly if it doesn't take too much of your time???

    Thanks Again

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Pivot Table - Count data From Multiple Columns

    Yes, post a sample file that accurately reflects your present set up - within that file outline also the "desired" results

  5. #5
    Registered User
    Join Date
    02-09-2011
    Location
    Durban, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Pivot Table - Count data From Multiple Columns

    Hi,

    I've attached as you suggested...I hope!
    My requirements are listed within the workbook on a sheet.

    Thank You
    Attached Files Attached Files

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Pivot Table - Count data From Multiple Columns

    I will try and look at this at some point in depth but the fact you intend to store each day on a separate sheet and have separate files per month basically means whatever approach you adopt it will be cumbersome.

    It is always best to store data in a coherent tabular manner - to think along the lines of database storage.

    In a database for ex you would not have a separate table for each day - and/or separate databases for each month.

    You would have a single database with a single table in which one field represented date value.

    In reality you should be storing your data along the lines of:


    Date | Mach No. | Time In | Batt Out | Batt In | Time Out | Elapsed | Charger No. | Attendant | Comment

    | denotes new "field" (column)
    so for repeat changes for a given machine that machine would have 2 transactions (rows) for that given date (for 3 you would have 3 transactions/rows)

    That said...

    I appreciate that from a data entry perspective having single sheets per day with 1 row per machine might well be the only practical solution from your perspective.
    When it comes to conducting analysis on the data you would be best served putting code/approaches in place that consolidate the daily sheets into a single data set as outlined.

    From that single set you could generate a multitude of Pivot Charts / Tables etc with ease and efficiency.

    FWIW, I don't believe (personally) that Multi Consolidation Pivots are viable in this instance - you will need to consolidate first.

  7. #7
    Registered User
    Join Date
    02-09-2011
    Location
    Durban, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Pivot Table - Count data From Multiple Columns

    Thank You for your advice. Unfortunately, the people who would input the data are not the most competent in terms of using a pc, therefore I've got to make the input part of the sheet as easy as possible
    I'm just gonna have to find a way around the storage and analysis issue.

    Thanks

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Pivot Table - Count data From Multiple Columns

    Attached would be the earlier suggestion "in action"

    A button on one sheet that consolidates the daily sheets for sake of subsequent analysis - the Pivots will update as part of the process.

    This is not bullet proof by any means and assumes a consistent layout across all daily sheets.
    I'm afraid approaching this as you have things won't be straightforward whichever route you take.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    02-09-2011
    Location
    Durban, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Pivot Table - Count data From Multiple Columns

    hi,

    i put your solution on trial and it seems to be working well. Thank you.
    I would also like to analyse the 'time in' column from the data sheet you created to track the no of batt. changes done per hour per month
    eg. 11:00 to 12:00 = 50 batt changes
    12:00 to 13:00 = 23 batt changes
    02:00 to 03:00 = 11 batt changes etc.
    Is this possible on a pivot chart? I've attached a workbook

    Thank You
    Attached Files Attached Files
    Last edited by Ashraf1; 02-17-2011 at 02:32 PM.

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Pivot Table - Count data From Multiple Columns

    see if the attached is along the right lines...

    FWIW I'd make the point that the way you're calculation Duration columns on the daily sheets may cause you problems
    (generally better to store time values as Time rather than Decimal hours etc...)
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    02-09-2011
    Location
    Durban, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Pivot Table - Count data From Multiple Columns

    WORKS LIKE A CHARM.......damn, you are smart

    Thanks a Million

  12. #12
    Registered User
    Join Date
    02-09-2011
    Location
    Durban, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Pivot Table - Count data From Multiple Columns

    Need your help....AGAIN

    I've used a circ ref formula to create a time stamp for 'time in' column, everytime data is entered into 'attendant' column....this works fine but has messed up calculations for 'time elapsed' and 'downtime' columns. Can you please take a look at this?

    Also, on the pivot table, I've introduced a chart to count the no of changes/day but I can't get the horizontal axis on the chart to reflect a 'day' instead of a date

    Thank You in Advance....
    Attached Files Attached Files

  13. #13
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Pivot Table - Count data From Multiple Columns

    Quote Originally Posted by Ashraf1
    ...on the pivot table, I've introduced a chart to count the no of changes/day but I can't get the horizontal axis on the chart to reflect a 'day' instead of a date
    Assuming you will have more than 7 days realistically you will want to add a Column at source to hold the "ddd" value and use that in the Pivot as Row Label.

    Quote Originally Posted by Ashraf1 View Post
    I've used a circ ref formula to create a time stamp for 'time in' column, everytime data is entered into 'attendant' column....this works fine but has messed up calculations for 'time elapsed' and 'downtime' columns.
    New thread for the above please.

  14. #14
    Registered User
    Join Date
    02-09-2011
    Location
    Durban, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Pivot Table - Count data From Multiple Columns

    Hi, would only need 7 days ie sun to sat. Pivot to show count of changes on Mondays;Tues etc for a month. Date would not matter...managed to get a pivot of the data sheet but need the horizontal axis to show days of the week without a date...thanks

  15. #15
    Registered User
    Join Date
    02-09-2011
    Location
    Durban, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    23

    Smile

    Sorry, wrong post...
    Attached Files Attached Files
    Last edited by Ashraf1; 02-22-2011 at 08:02 AM. Reason: I am slow....

  16. #16
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Pivot Table - Count data From Multiple Columns

    Quote Originally Posted by Ashraf1
    ...would only need 7 days ie sun to sat. Pivot to show count of changes on Mondays;Tues etc for a month.
    I'm not sure I made my earlier point very well.

    If you have greater than a weeks worth of transactions (ie > 7 days) then your approach won't work.

    You can not (AFAIK) group a Pivot Table by the Weekday (Mon, Tue) of the underlying Date values.

    You will need to create an additional column at source that stores the weekday [=TEXT(date,"ddd")] by transaction and use that new column as the Row Label in your Pivot.

  17. #17
    Registered User
    Join Date
    02-09-2011
    Location
    Durban, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    23

    Smile Re: Pivot Table - Count data From Multiple Columns

    tried wat u suggested....not sure if I did it correctly though..
    it works to an extent but my problem would be that the 'weekday' would have to be input manually daily for every transaction
    ...is there an easier way to have the weekday come up automatically in a column but not get updated when the workbook is re-opened? ie not affected by NOW function
    Please See attached
    Attached Files Attached Files

  18. #18
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Pivot Table - Count data From Multiple Columns

    You needn't store Day for each transaction - simply add to the consolidated "Data" sheet as part of the VBA consolidation routine

    In your sample remove "Day" columns from 01 March sheet.

    Modify VBA to below:

    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    02-09-2011
    Location
    Durban, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Pivot Table - Count data From Multiple Columns

    hi,

    I used the above code and it works fine for 'ddd' issue, however everything else on the data sheet (FORMATTING) has gone crazy. I know that the code may need a few tweeks to suit the new column entry but I have no clue where to start.

    Thank You
    Attached Files Attached Files

  20. #20
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Pivot Table - Count data From Multiple Columns

    Sorry about that !

    Change:

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    Last edited by DonkeyOte; 02-23-2011 at 07:43 AM.

  21. #21
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Pivot Table - Count data From Multiple Columns

    Based on the last sample you also need to change value of C_COLUMNS from 9 to 8 as you have 8 columns per instance (excl. machine number)

  22. #22
    Registered User
    Join Date
    02-09-2011
    Location
    Durban, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Pivot Table - Count data From Multiple Columns

    Think I'm getting better at this...messed around with code before you posted and got about 80% of the adjustment correct!
    Works perfectly now with your adjustments

    PS. Pls don't apologise...i feel bad enough already 'cos i've taken up so much of your time

+ 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