+ Reply to Thread
Results 1 to 13 of 13

Offset/vlookup in a sumifs function

  1. #1
    Registered User
    Join Date
    09-05-2012
    Location
    New York
    MS-Off Ver
    Excel 365
    Posts
    14

    Offset/vlookup in a sumifs function

    I have two sets of ranges in two different tabs.

    One has A through D with values going down. The other range has A through D (in different order) with the Country of Origin. I forgot to add, the order of the excel file is incorrect. The Country of Origin column is in B and A through D is in C. I cannot change it as it is locked from another party.

    I want to get the sum of the values based on Country of Origin using sumifs. I tried offset and Vlookup, but had no luck.
    Attached Files Attached Files
    Last edited by kakaman; 10-08-2015 at 04:21 PM.

  2. #2
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Offset/vlookup in a sumifs function

    I don't see where you get 12 and 14 from, US = 13, Canada = 13.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    *** Must be confirmed as an Array Formula by using Shift Ctrl and Enter, not just Enter ***

    If you get 0 results then this has not been done correctly.

  3. #3
    Registered User
    Join Date
    09-05-2012
    Location
    New York
    MS-Off Ver
    Excel 365
    Posts
    14

    Re: Offset/vlookup in a sumifs function

    Quote Originally Posted by jason.b75 View Post
    I don't see where you get 12 and 14 from, US = 13, Canada = 13.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    *** Must be confirmed as an Array Formula by using Shift Ctrl and Enter, not just Enter ***

    If you get 0 results then this has not been done correctly.
    I tried copy and pasting the formula but I keep getting 0, even as an array formula. Do you mind attaching an excel file? I also have Excel 2010, not sure if that makes a difference.

  4. #4
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Offset/vlookup in a sumifs function

    Here ya go, this is done with your sample file from post #1, with the formula in C14 and D14.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    12-13-2013
    Location
    Calgary,AB,Canada
    MS-Off Ver
    2016,O365
    Posts
    236

    Re: Offset/vlookup in a sumifs function

    if your source file is big, I prefer to use helper column

    1. A7=VLOOKUP(B7,$B$2:$C$5,2,FALSE), copy to A10
    2. C20=SUMPRODUCT(($A7:$A10=C$13)*($C$7:$C$10)) , copy to D20

  6. #6
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Offset/vlookup in a sumifs function

    Quote Originally Posted by CAABYYC View Post
    if your source file is big, I prefer to use helper column

    1. A7=VLOOKUP(B7,$B$2:$C$5,2,FALSE), copy to A10
    2. C20=SUMPRODUCT(($A7:$A10=C$13)*($C$7:$C$10)) , copy to D20
    If you're going to use a helper to make it more efficient then might as well maximise the effect.

    1. Index and Match is more efficient than Vlookup.
    2. Sumif is more efficient than Sumproduct.

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Offset/vlookup in a sumifs function

    Quote Originally Posted by jason.b75 View Post
    1. Index and Match is more efficient than Vlookup.
    They are about the same efficiency-wise but INDEX is more versatile.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  8. #8
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Offset/vlookup in a sumifs function

    Quote Originally Posted by Tony Valko View Post
    They are about the same efficiency-wise but INDEX is more versatile.
    I did a timer test with the 2 a couple of years ago, index / match was about 20% faster to recalculate, much to my annoyance at the time, (there was a certain mvp that I wanted to prove wrong).

    That said, it does need a significant amount of data for the difference to be noticeable.

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Offset/vlookup in a sumifs function

    In Excel 2002 I filled column A with the row numbers 1 to 65536.

    In column B, B1:B65536 I entered random numbers.

    I then tested the calculation times for these 2 formulas:

    Formula 1: =VLOOKUP(50000,A:B,2,0)

    Formula 2: =INDEX(B:B,MATCH(50000,A:A,0))

    I did 5 calculations of each formula and averaged those results.

    Data Range
    D
    E
    F
    G
    H
    I
    J
    1
    Test1
    Test2
    Test3
    Test4
    Test5
    Average
    2
    Formula 1
    0.00195
    0.00194
    0.00195
    0.00194
    0.00195
    0.001946
    3
    Formula 2
    0.00194
    0.00195
    0.00194
    0.00197
    0.00193
    0.001946

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Offset/vlookup in a sumifs function

    Quote Originally Posted by Tony Valko View Post
    In Excel 2002...
    I use Excel 2002 for this because I have a file created in Excel 2002 dedicated to exactly this subject.

    It's not important to know that one formula takes x amount of time to calculate and another formula takes y amount of time to calculate but it's good to know that one formula is more efficient than the other.

    I do this kind of testing extensively.

  11. #11
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Offset/vlookup in a sumifs function

    I'm starting to wonder what other factors can make significant differences. Other applications, background processes, etc.

    It's interesting to note that your testing shows that the process times are very close together, where as mine have a much greater difference.

    For the purpose of testing, I entered =ROW() into A1:A50000, then copy and paste values.

    In B1, =VLOOKUP(A1,$A$1:$A$50000,1,0) for the first run, then replace that with =INDEX($A$1:$A$50000,MATCH(A1,$A$1:$A$50000,0)) for the second run.

    Then I ran a loop for 10 cycles to force calculation and post the timings.

    Sorting both sets of times slowest to fastest in order to compare closest possible values, index was 7% faster on the quickest cycle, but on the other 9 cycles the difference was less than 1%, 6 of those less than 0.01%.

    What was more interesting was the difference between the fastest and slowest cycles of the same formula.
    Please Login or Register  to view this content.
    Given these variations, it is easy to see where tests can favour one method if not evaluated correctly.

  12. #12
    Registered User
    Join Date
    09-05-2012
    Location
    New York
    MS-Off Ver
    Excel 365
    Posts
    14

    Re: Offset/vlookup in a sumifs function

    Perfect, thanks everyone!

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Offset/vlookup in a sumifs function

    Quote Originally Posted by jason.b75 View Post
    I'm starting to wonder what other factors can make significant differences. Other applications, background processes, etc.
    Yeah, everyone would get different results based on those factors plus some.

    I use the timer code found here:

    http://msdn.microsoft.com/en-us/library/aa730921.aspx

+ 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. sumifs + offset formula issue
    By jw01 in forum Excel General
    Replies: 6
    Last Post: 02-11-2015, 11:05 AM
  2. Dragging SUMIFS but need ranges to offset
    By LK0001 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-06-2014, 09:57 AM
  3. Help with OFFSET/MATCH/SUMIFS formula
    By brianjluke in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-22-2013, 10:02 AM
  4. Replies: 3
    Last Post: 01-29-2013, 01:30 PM
  5. Replies: 10
    Last Post: 10-04-2012, 02:11 AM
  6. Vlookup / SumIFS / Other related Function Needed
    By blakey56 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-02-2012, 07:57 PM
  7. User Defined Function using Sumifs, Offset, Match and CountA
    By PeterW2020 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-29-2011, 02:29 AM

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