+ Reply to Thread
Results 1 to 8 of 8

Combine SUM, INDEX and MATCH

  1. #1
    Registered User
    Join Date
    11-03-2018
    Location
    Oslo, Norway
    MS-Off Ver
    2013
    Posts
    24

    Combine SUM, INDEX and MATCH

    Hello.
    I got some 10000 rows, and if I use SUMIFS the file will hang.
    I'm therefore trying to combine SUM, INDEX and MATCH to sum some rows based upon two criteria's. I've added a demo file.
    What I want to do is to sum the corresponding rows based upon two criteria's and return the sum next to one of the criteria's. If you look at my file, you'll understand what I think.

    I've tried every demo I've found online, but I'm only receiving #NA or #value, so I don't know what I'm doing wrong.

    Can anyone please help me?
    Attached Files Attached Files

  2. #2
    Forum Expert dosydos's Avatar
    Join Date
    12-09-2015
    Location
    Massachusetts
    MS-Off Ver
    365(PC) V:2308
    Posts
    1,472

    Re: Combine SUM, INDEX and MATCH

    could you paste your sumifs formula you were using before that was causing your sheet to run slowly? There might be a way to make it run quicker, vs making another formula that might be array based and take just as long to run if not longer.

  3. #3
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: Combine SUM, INDEX and MATCH

    If I'm understanding correctly, the code would be:
    Please Login or Register  to view this content.
    I am genuinely struggling to come up with a faster construction. Like, Boolean SUMPRODUCT might do it, but I think it would be tough to validate?

    I agree with dosydos -- using arrayed Lookups with INDEX(MATCH) would for sure be in the neighborhood of 1000x slower.
    Click the [* Add Reputation] Button to thank people for help!
    Post Attachment: Click [Go Advanced] under the reply box; then click [Manage Attachments] to launch the attachments dialogue.
    Mark Thread Solved: Go to the top of the first post; Select [Thread Tools] dropdown; Pick the [Mark thread as Solved] option.

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Combine SUM, INDEX and MATCH

    Are you required to use a worksheet formula? This is the kind of thing that looks like it might be better accomplished using a pivot table (https://www.excel-easy.com/data-****...ot-tables.html ). Obviously, your sample is a much smaller database than the real one, but the procedure should be the same:

    1) Select source (A2:C10 in your sample file -- if you select one cell in your source, Excel will usually expand the selection as best as it can guess).
    2) Insert->Pivot Table. Confirm choices for source data and output cell/range.
    3) I put MVA-Code as row labels, MVA-term as column labels, and sum of Line-Sum in the values field for the pivot table.
    4) (optional) Select the column label dropdown and filter the results for MVA-term 6 only.

    Where the main concern is computation speed, the big advantage of a pivot table for this is that pivot tables are very fast -- almost always executing much faster than worksheet formulas. That's probably the direction I would be going for something like this -- figure out how to use a pivot table for the task.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: Combine SUM, INDEX and MATCH

    That's a good point Shorty, but I mean, we're dealing with only 10,000 rows. I'm not sure that's a big enough dataset for a relatively, very simple SUMIFS to even care. I kinda feel like there's probably something else going on, and this behavior with SUMIFS is only the symptom of some greater root cause.

    Like when I populated it up to 10,000ish rows of garbage data using INT(RAND()*10) for all three columns, I could mash F9 and the 30 SUMIFS updated without even blinking. Actually, that's probably worth checking -- OP, how many SUMIFS total are you running here?

  6. #6
    Registered User
    Join Date
    11-03-2018
    Location
    Oslo, Norway
    MS-Off Ver
    2013
    Posts
    24
    I can't use a Pivot table because I need the result other places that can't access a Pivot. So, I need to do this by code.
    And I would like that code to be a combination of SUM, INDEX and MATCH. Can someone please help me with such a code?
    Last edited by abrj; 12-14-2018 at 01:40 PM.

  7. #7
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: Combine SUM, INDEX and MATCH

    Quote Originally Posted by abrj View Post
    And I would like that code to be a combination of SUM, INDEX and MATCH.
    If your problem is that SUMIFS is too slow,
    cash money you will not fix that problem with some arrayed monstrosity of SUM, INDEX, and MATCH; you will for sure have an even worse performance problem.

    Can you post the exact syntax of the SUMIFS you are using? I feel like you might be catching a marching range (eg, $A$1:A1000 or something) or something equally arcane, that is your actual source of pain.

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Combine SUM, INDEX and MATCH

    Another thought:

    Do $C$3:$C$15000, $A$3:$A$15000 and $B$3:$B$15000 also contain formulas?
    Might there be some recalculations happening due to volatile functions there or elsewhere?
    Dave

+ 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. [SOLVED] Combine INDEX(MATCH with INDIRECT (maybe?)
    By sma365 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-19-2017, 04:41 PM
  2. Combine index match and sumproduct
    By Esrei in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-25-2013, 08:08 AM
  3. [SOLVED] How to combine SUMIF, INDEX and MATCH
    By BeachRock in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-28-2013, 04:58 PM
  4. How Do I Combine OFFSET With INDEX MATCH
    By joconnor125 in forum Excel General
    Replies: 8
    Last Post: 06-15-2012, 04:47 AM
  5. [SOLVED] Combine MATCH and INDEX
    By SubwAy in forum Excel General
    Replies: 13
    Last Post: 05-31-2012, 11:53 AM
  6. Replies: 0
    Last Post: 10-10-2011, 07:29 PM
  7. How to combine the INDEX and MATCH functions?
    By Anna A in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-25-2010, 03:47 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