+ Reply to Thread
Results 1 to 6 of 6

Thread: summing and ranking a table in excel

  1. #1
    Registered User
    Join Date
    02-13-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    4

    summing and ranking a table in excel

    I have a table with 4 columns City, Industry, Title and Amount
    I need to sum the data by City i.e. total for Milan = 2200 and London = 1300 and then rank city based on total. Milan will be ranked 1 and London 2
    I then need to sum and rank on Industry within City i.e. Milan and Telecommunication = 1700 and Milan and IT = 500 so Milan and Telecommunications will be ranked 1 and Milan and IT will be ranked 2
    It needs to be further summed and ranked by Title within Industry within City:
    Milan and IT and DBA = 500 and ranked 1
    Milan and Telecommunication and System Administrator = 800 and ranked 1 (within the Milan and Telecommunications group)
    Milan and Telecommunication and Call Centre Agent = 300 and ranked 3 (within the Milan and Telecommunications group)
    Milan and Telecommunication and Legal Advisor = 600 and ranked 2 (within the Milan and Telecommunications group)

    Please help me figure this one out. I have attached a sample of the table with data and expected results
    Attached Files Attached Files
    Last edited by prebash; 02-14-2012 at 02:50 AM. Reason: answer solved my problem :)

  2. #2
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: summing and ranking a table in excel

    Try this:

    In H2:

    =SUMIF($A$2:$A$9,A2,$D$2:$D$9)

    copied down

    In I2:

    =SUMIFS($D$2:$D$9,$A$2:$A$9,A2,$B$2:$B$9,B2)

    in J2:

    =SUMIFS($D$2:$D$9,$A$2:$A$9,A2,$B$2:$B$9,B2,$C$2:$C$9,C2)

    Those are the helper columns...

    Now to get rankings...

    in K2:

    =SUMPRODUCT(--(COUNTIF(OFFSET(H$2,,,ROW(H$2:H$9)-ROW(H$2)+1),H$2:H$9)=1),--(H$2:H$9>H2))+1

    copied down

    in L2:

    =SUMPRODUCT(--(COUNTIF(OFFSET(I$2,,,ROW(I$2:I$9)-ROW(I$2)+1),I$2:I$9)=1),--($A$2:$A$9=$A2),--(I$2:I$9>I2))+1

    copied down

    in M2:

    =SUMPRODUCT(--(COUNTIF(OFFSET(J$2,,,ROW(J$2:J$9)-ROW(J$2)+1),J$2:J$9)=1),--($A$2:$A$9=$A2),--($B$2:$B$9=$B2),--(J$2:J$9>J2))+1

    copied down.

    I found one mismatch to your "expected data" at M6... not sure if it is mine or your error.
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  3. #3
    Registered User
    Join Date
    02-13-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    4

    Thumbs up Re: summing and ranking a table in excel

    That works perfectly. THANK YOU!!
    Yes it was my mistake in G6

  4. #4
    Registered User
    Join Date
    02-13-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: summing and ranking a table in excel

    actually just realised that M^gives the incorrect answer, it should be ranked 2 because M7 is ranked 1 for the two within that city, and industry

  5. #5
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: summing and ranking a table in excel

    Does this fix it?

    =SUMPRODUCT(--(COUNTIF(OFFSET(J$2,,,ROW(J$2:J$9)-ROW(J$2)+1),J$2:J$9)>=1),--($A$2:$A$9=$A2),--($B$2:$B$9=$B2),--(J$2:J$9>J2))+1

    in M2, copied down.
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  6. #6
    Registered User
    Join Date
    02-13-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: summing and ranking a table in excel

    Yes it does. Thank you kindly!

+ 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.2.0