+ Reply to Thread
Results 1 to 5 of 5

Aggregating data with differing ranges

  1. #1
    Registered User
    Join Date
    03-27-2013
    Location
    Amersfoort, The Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    3

    Aggregating data with differing ranges

    Hello!

    First off, I apologize if I'm somewhat vague. I couldn't come up with a better title.

    I have a relatively large database with number of votes per voting district (I can share this data - it's not protected or anything). These voting districts are of course located in municipalities. I want a total of votes per municipality. The trouble is that the number of voting districts per municipality differs, so with my limited knowledge I am left in the dark on how to solve this. I'd just do it manually, but with more than 90k cases, that would be quite an ordeal.

    I've attached the first 32 cases. Details:

    A2-33 = municipality (number)
    B2-33 = municipality (name)
    C2-33 = voting district (name + postal code)
    D2-33 = votes of two parties I have data of. So this number is X votes for the two parties per voting district
    E2-33 = total number of votes (per voting district)

    What I would like to have is:

    F2-33 -> number of votes for the two parties per municipality (so I want the data of D2-33 aggregated per municipality number (A2-33))
    G2-33 -> number of total votes per municipality (this data is now in E2-33 per voting district)

    Many thanks if you could help me!

    PS In the attached document I left some non-working formula in G2 and H2 by accident (it's irrelevant).
    Attached Files Attached Files
    Last edited by Curver21; 03-27-2013 at 11:41 PM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Aggregating data with differing ranges

    Hi and welcome to the forum

    In G2, copied down, use this - it will extract unique entries from Col B...
    =IFERROR(INDEX($B$2:$B$33,MATCH(0,INDEX(COUNTIF($G1:G$1,$B$2:$B$33),0,0),0)),"")
    Then in H2, copied down, use this - it will add the votes for each entry in G...
    =IF(G2="","",SUMIF(B:B,G2,E:E))

    If you want to put these somewhere else, move them both, but you will have to adjust the "COUNTIF($G1:G$1" part.

    Also, I just used the range you provided (down to row 33) adjust this down as as far as you need it to go
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    03-27-2013
    Location
    Amersfoort, The Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Aggregating data with differing ranges

    Thanks for the quick response! I'll have to try this in 10/13 hours, because my Office cannot change language for some reason. And when I translate the function to Dutch, it won't work at all (just gives an error, highlighting the '$B$33,MATCH' section). But I'm sure it works, so thanks again!
    Last edited by Curver21; 03-28-2013 at 12:32 AM.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Aggregating data with differing ranges

    try changing the , to a ; it may be a regional setting problem

  5. #5
    Registered User
    Join Date
    03-27-2013
    Location
    Amersfoort, The Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Aggregating data with differing ranges

    That did the trick. Thanks a lot! The calculation is going to take some time though.
    Last edited by Curver21; 03-28-2013 at 01:28 AM.

+ 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