+ Reply to Thread
Results 1 to 6 of 6

Complex matrix count and rollup

  1. #1
    Registered User
    Join Date
    01-11-2010
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    4

    Complex matrix count and rollup

    I am attempting to solve a counting problem with the data in the attached spreadsheet.

    Without getting in to too much detail as to why I wish to do this, the problem I have is like this:

    Each user may has one or many rows of data. Each user will never have two identical make/region/rating combinations.

    The matrix to the right of the first four columns puts a '1' where the combination of data matches that for a particular user.

    Each user's '1's in the matrix are rolled up to the very first row that the user appears in. Eg. User 1 has a '1' under the Audi, AM, 2 box for row 4, and a '1' under the BMW, EU, 3 box for row 5 - however both '1's appear in row 4 only...

    ...row 5, and any subsequent rows for that user (if there were any more), will simply contain '0's.

    This will eventually be extended to many hundreds of users and perhaps 10 manufacturers (but always keeping the three regions and the five ratings).

    Can someone suggest a programmatic way of calculating the zeros and ones? Replacing the example data with formulae or VB functions?

    Thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Complex matrix count and rollup

    Unmerge the cells in the first two rows and duplicate the data. Then in E4 and copy across and down,

    =($B4=E$1) * ($C4=E$2) * ($D4=E$3) * 1

    (Part of) the results looks like this:

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Complex matrix count and rollup

    With your posted structure...
    Try this:

    Please Login or Register  to view this content.
    Otherwise, if you UNmerge the heading cells and enter values (like shg suggested):
    Please Login or Register  to view this content.
    Either way, copy the formula across and down through AH12.

    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  4. #4
    Registered User
    Join Date
    01-11-2010
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Complex matrix count and rollup

    Thank you both, that certainly looks like what I'm after. I hadn't even considered unmerging the cells to simplify the problem; it's obvious now!

    I shall have a try at attempting to understand what is happening in these formulae and extending them to the additional manufacturers, as mentioned in my original post.

    Thanks again.

  5. #5
    Registered User
    Join Date
    01-11-2010
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Complex matrix count and rollup

    Could I perhaps add the following extra caveat...

    If I added a 7th user to the provided example, with the data BMW, AM, 3 and BMW, AM 2 - how would it be possible to now roll these up horizontally in the matrix and only count the maximum rating?

    A point of clarification also - the matrix is essentially a list of boolean values with just a 1 or 0 if the combination is present. Ron's first solution summed the number of instances of each combination, however I've remediated this.

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Complex matrix count and rollup

    OK...I added 2 more user combinations in rows 13 and 14

    The below formulas calculate the maximum rating for a User/Make/Region.

    Please Login or Register  to view this content.

    Whichever scenario you use, copy E4 across and down through AH4.

    (I attached a sample workbook with both scenarios)

    Does that help?
    Attached Files Attached Files

+ 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