+ Reply to Thread
Results 1 to 13 of 13

Faster way to sum rows and columns that match a specific criteria

  1. #1
    Registered User
    Join Date
    08-11-2017
    Location
    Bellevue, WA
    MS-Off Ver
    2013
    Posts
    7

    Faster way to sum rows and columns that match a specific criteria

    Hi, I have a data set with repeating row headers and unique column headers. I am trying to sum the data into unique row headers.

    My current solution is to use {=IF(ROW LIST=NAME,IF(COLUMN LIST=DATE,DATA RANGE,0),0)} (CTRL + SHIFT +ENTER)
    However, this formula can be slow if used across a large number of cells. Is there some form of sum index match or whatnot to make this work?

    Date 1 Date 2 Date 3

    aa 691 691 691
    bb 302 302 302
    cc 84 84 84
    dd 22 22 22
    ee 10 10 10
    ff 97 97 97
    aa 329 329 329
    bb 619 619 619
    cc 542 542 542
    dd 237 237 237
    ee 66 66 66
    ff 18 18 18

    Date 1 Date 2
    aa
    bb
    cc
    dd
    ee
    ff

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,165

    Re: Faster way to sum rows and columns that match a specific criteria

    Have you tried SUMIF?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    08-11-2017
    Location
    Bellevue, WA
    MS-Off Ver
    2013
    Posts
    7

    Re: Faster way to sum rows and columns that match a specific criteria

    That works well too, but what I'm trying to do is be able to automatically match the column header. SUMIFS rely on correct positioning and since the data I'm pulling is from another worksheet, I want to be sure it grabs the correct column, as I won't be the only one in the file and don't want to double check positioning every time.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Faster way to sum rows and columns that match a specific criteria

    It's imnpossible to visualise this from the poor layout that the forum platform applies.

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? Please don't attach a picture of one (no-one will want to re-type all your stuff before starting).

    1. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution is also shown (mock up the results manually).

    3. Make sure that all confidential information is removed first!!

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  5. #5
    Registered User
    Join Date
    08-11-2017
    Location
    Bellevue, WA
    MS-Off Ver
    2013
    Posts
    7

    Re: Faster way to sum rows and columns that match a specific criteria

    Sure, no problem. So to reiterate, I'd like to get these results without using SUMIF(s) because I'd like to match dates, and avoid using =SUM(IF( because that'll end up with long calc times over big data sets. Thank you very much.
    Attached Files Attached Files

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Faster way to sum rows and columns that match a specific criteria

    Is this it? In J4, copied across and down:

    =SUMPRODUCT(($A$3:$A$26=$I4)*($B$2:$F$2=J$3)*$B$3:$F$26)

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,165

    Re: Faster way to sum rows and columns that match a specific criteria

    In J4 copied across and down:

    =SUMPRODUCT(($B$2:$F$2=J$3)*($A$3:$A$26=$I4),$B$3:$F$26)

  8. #8
    Registered User
    Join Date
    08-11-2017
    Location
    Bellevue, WA
    MS-Off Ver
    2013
    Posts
    7

    Re: Faster way to sum rows and columns that match a specific criteria

    I have read that SUMPRODUCT is calc intensive in big data sets. Are there any other methods that would be faster, or is this the best option?

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Faster way to sum rows and columns that match a specific criteria

    How big is big? It'll certainly be faster than your clunky array....

  10. #10
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Faster way to sum rows and columns that match a specific criteria

    I'm not sure how much more efficient it's going to be. But if you want to avoid SUMPRODUCT...

    Try...
    =SUMIFS(INDEX($B$3:$F$26,,MATCH(J$3,$B$2:$F$2,0)),$A$3:$A$26,$I4)

    Copy across and down.

    Basically index is used to return entire column where date matches.
    "Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something."
    ― Robert A. Heinlein

  11. #11
    Registered User
    Join Date
    08-11-2017
    Location
    Bellevue, WA
    MS-Off Ver
    2013
    Posts
    7

    Re: Faster way to sum rows and columns that match a specific criteria

    Quote Originally Posted by CK76 View Post
    I'm not sure how much more efficient it's going to be. But if you want to avoid SUMPRODUCT...

    Try...
    =SUMIFS(INDEX($B$3:$F$26,,MATCH(J$3,$B$2:$F$2,0)),$A$3:$A$26,$I4)

    Copy across and down.

    Basically index is used to return entire column where date matches.
    Yes! This is what I was looking for! Thank you CK76! I like to evaluate formulas and since SUMPRODUCT uses lots of true/falses, I disklike it. The worksheets communicate with the server, so any increase in efficiency will be helpful.

    Thanks everyone that helped me with this.

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,165

    Re: Faster way to sum rows and columns that match a specific criteria

    You specifically said at the top of the thread, when I asked that question, that you did not want to use SUMIFS, so it was avoided!

    Glad you have your resolution, though.

  13. #13
    Registered User
    Join Date
    08-11-2017
    Location
    Bellevue, WA
    MS-Off Ver
    2013
    Posts
    7

    Re: Faster way to sum rows and columns that match a specific criteria

    Ah, I get what you're saying. My intention was to say that I wanted more than just the SUMIFS, because SUMIFS by itself doesn't match columns, only rows. I wanted the tracking ability of index match with the summing ability of sumifs or just summing. Sorry for the confusion. I'm pretty ecstatic about this new use of SUMISF + INDEX/MATCH though. Thank you for helping me work it through.

+ 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. Index Match with Multiple criteria in rows and columns
    By amy22x3 in forum Excel General
    Replies: 1
    Last Post: 06-22-2016, 05:22 PM
  2. [SOLVED] INDEX+MATCH with multiple criteria across both rows and columns
    By george_k in forum Excel General
    Replies: 3
    Last Post: 10-26-2012, 04:11 PM
  3. Print specific rows/columns IF a cell meets criteria
    By tiannaleft in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-16-2012, 08:51 AM
  4. Returning specific columns from all rows that match criteria
    By kkelly in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-10-2012, 04:16 PM
  5. [SOLVED] Deleting multiple rows with specific criteria in multple columns
    By cb10 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-13-2012, 10:16 AM
  6. Match multiple criteria in rows and columns
    By JuJuBe in forum Excel General
    Replies: 5
    Last Post: 06-02-2010, 03:47 PM
  7. [SOLVED] Sum rows if two columns = specific criteria.
    By Jeff in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-01-2006, 08:35 PM

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