+ Reply to Thread
Results 1 to 6 of 6

Formula to Count and Group Items

  1. #1
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Formula to Count and Group Items

    I have data that looks like this:

    Group Item Value
    1 A 0
    1 A 2
    1 C 0
    1 B 1
    1 A 1
    2 B 1
    2 B 2
    2 A 0
    2 A 0
    2 A 2
    3 A 1
    3 C 0
    3 A 1
    3 C 2
    3 A 1

    I want to use formulas to summarize the table like this:

    Group
    1 1A0 1A1 1A2 1B1 1C0
    2 2A0 1A2 1B1 1B2
    3 3A1 1C0 1C2

    I know that this can be done via VBA (and would be easier), but the file is to be shared via email and our email filter doesn't like .xlsm files, so I'm trying to avoid this if possible.
    1. Include a sample workbook with an example of the result you want
    2. Use [CODE] and [FORMULA] wrappers for your VBA code or excel formulas
    3. If your question has been answered, mark the thread as SOLVED and click on the "Add Rep" star to thank whoever helped you.

  2. #2
    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: Formula to Count and Group Items

    Not quite the same layout, but being a Pivot Table arguably much simpler and far more flexible and efficient.
    Attached Files Attached Files
    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.

  3. #3
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Formula to Count and Group Items

    Thank you Richard,

    Pivot tables are definitely more efficient. I am looking to have 1 row per group and only 6 columns in the resulting table, in the format shown. I wasn't able to produce this result from a Pivot table. I think the Pivot table provides a good supplement to the report I want though, so thanks for the contribution!

    K64

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

    Re: Formula to Count and Group Items

    Note: This solution does not arrange the summarized table in the same order as in post #1.
    The solution makes use of four helper columns, which could be hidden for aesthetic purposes. The formulas of the helper columns respectively
    1) combine the item and value: =B2&C2
    2) count per group: =COUNTIFS(D$2:D$16,D2,A$2:A$16,A2)
    3) combine count, item and value: =IF(E2=1,E2&D2,IF(COUNTIFS(D$2:D2,D2,A$2:A2,A2)=E2,E2&D2,""))
    4) rank by group: =IF(F2="","",SUMPRODUCT(($A$2:$A$16=A2)*($F$2:$F$16>F2))+1)
    The array entered formula* which populates the table (J7:N9):
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Array entered formulas are confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.
    Let me know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  5. #5
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Formula to Count and Group Items

    Thanks JeteMc! That is exactly what I was hoping I could do. It doesn't matter that it's not in the same order, since if I need to, I can define a custom order and rank by that.

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

    Re: Formula to Count and Group Items

    You're Welcome and thank you for the feedback. Please take a moment to mark the thread 'Solved' using the thread tools link above your first post. I hope that you have a blessed day.

+ 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: 12
    Last Post: 04-01-2016, 03:57 PM
  2. [SOLVED] A (relatively) simple formula to count items per month
    By Ben1985 in forum Excel General
    Replies: 5
    Last Post: 02-19-2015, 07:01 AM
  3. [SOLVED] search for an identifier in a group of 17 items. if found count it once
    By joannelittell in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-11-2014, 03:45 AM
  4. Formula to count repeat items
    By ravinella in forum Excel General
    Replies: 1
    Last Post: 03-05-2009, 06:39 PM
  5. How to count and group items in a list depending on size of list?
    By Simon Lloyd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-12-2006, 07:20 PM
  6. How to count items in a list and group depending on size of list?
    By Simon Lloyd in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-27-2006, 07:14 PM
  7. [SOLVED] How do I set up a formula to count multiple items?
    By Mikaka in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-23-2006, 02:30 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