+ Reply to Thread
Results 1 to 21 of 21

Index? Sumproduct?

  1. #1
    Registered User
    Join Date
    05-30-2014
    Posts
    13

    Index? Sumproduct?

    Hello,

    I'm looking for a formula that will get me the proper rate from my "rate sheet" and display it in Column M of my data sheet.
    Each customer will have a code, and each code will have several rates for different "date ranges".
    I would like the formula to check the date of shipment and the customer code on data sheet, and then figure out the rate for that customer code and date range.

    Anyone know how to do this?

    Data Sheet
    A - Date of shipment
    L - Customer Code
    M - (where new rate formula should go)

    Rate Sheet
    A - Start date of rate
    B - End date of rate
    J - Customer Code
    K - Rate

    Here is workbook
    example4.xlsx

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

    Re: Index? Sumproduct?

    Isn't there something wrong with your example? The code is the same for all 3 rates. So how is Excel meant to know which one to pick? Can you take a look again at this?
    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.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

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

    Re: Index? Sumproduct?

    If the values for the codes are made unique, then it all works fine with INDEX:MATCH (attached).
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    05-30-2014
    Posts
    13

    Re: Index? Sumproduct?

    A customer may have 20 different rates for different date ranges but their code will always be the same. (that's why I set my example workbook with the same customer codes- that's the part I cant get around)

    Example
    Customer A has 3 shipments, 1 on jun 25, 1 on jul 2 and 1 on jul 9.
    His rate from jun 23 to jun 29 is 5$
    his rate from jun 30 to jul 6 is 10$
    his rate from jul 7 to jul 13 is 15$
    Last edited by tche misere; 06-20-2014 at 02:15 PM.

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

    Re: Index? Sumproduct?

    Dohh!! The penny drops. Try this (ARRAY FORMULA< set with CTRL + SHIFT + ENTER)

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

  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 2403
    Posts
    44,063

    Re: Index? Sumproduct?

    Dohh again.. I forgot to build in the customer code...

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

  7. #7
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Index? Sumproduct?

    A Non-Array version of the formula suggested by Glenn would be like this with the specified range...

    Please Login or Register  to view this content.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  8. #8
    Registered User
    Join Date
    05-30-2014
    Posts
    13

    Re: Index? Sumproduct?

    Ohh nice!!
    Thank you so much.. works great!

  9. #9
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Index? Sumproduct?

    You're welcome. Thanks for the feedback.
    If that takes care of your question, please mark your thread as solved by selecting Thread Tools (just above your first post) --> Mark thread as solved.
    Moreover you may also click on * (star) to Add Reputation to those who have put their time and efforts to help you in this forum. This is another way to say thanks to them.

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

    Re: Index? Sumproduct?

    Thanks for the feedback....

    I always forget the non-array version for multiple criteria...

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

    Re: Index? Sumproduct?

    Quote Originally Posted by Glenn Kennedy View Post

    I always forget the non-array version for multiple criteria...
    People seem to think that adding an additional INDEX function to avoid an array formula is better.

    It's not!
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

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

    Re: Index? Sumproduct?

    Tony, Interesting comment. Why do you say that (for my benefit as much as that of the OP)?

  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: Index? Sumproduct?

    I say it because its true!

    I tested these 2 formulas:

    Array entered:

    =INDEX(C:C,MATCH(1,(A1:A1000=10)*(B1:B1000=10),0))

    Non-array entered:

    =INDEX(C:C,MATCH(1,INDEX((A1:A1000=10)*(B1:B1000=10),0),0))

    The lookup values were found on row 500.

    Here are the calculation times for these 2 formulas:

    Data Range
    D
    E
    F
    G
    H
    I
    J
    1
    Test1
    Test2
    Test3
    Test4
    Test5
    Average
    2
    Array
    0.00093
    0.00090
    0.00090
    0.00090
    0.00090
    0.000906
    3
    Non-array
    0.00094
    0.00092
    0.00092
    0.00093
    0.00093
    0.000928


    The results you get will depend on the configuration of your machine.

    So, what advantage was gained by using the non-array formula?

    Maybe not having to remember to CSE is a benefit but the non-array version has no performance advantage over the array version.

    You can do your own tests. The timer code can be found here:

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

    Just remember that the results you get depend on what version(s) of Excel you test in and how your machine is configured.

  14. #14
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Index? Sumproduct?

    Yes.

    I once did a similar exercise in which I replaced all necessary parts (about five) of a longish array formula with INDEX constructions in order to force the equivalent array-processing.

    To cut a long story short, the formula practically crashed on me.

    I think that substituting a single INDEX has some merit, and I often use this method myself, though I would hesitate to suggest that it actually constitutes an "improvement" to do so.

    I would even go as far as to say that using INDEX as a pure substitute for CSE (and certainly when substituting more than one, as I attempted) is not only not as "good" an achievement (required key-combination aside, of course!) as some think, but by all accounts leaves you, at least in terms of efficiency and calculation speed, actually noticeably worse.

    It is an extra function call, after all...

    Regards
    Last edited by XOR LX; 06-20-2014 at 04:56 PM.
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  15. #15
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Index? Sumproduct?

    Quote Originally Posted by Tony Valko View Post

    The lookup values were found on row 500.
    What if lookup value is found on row 5000.
    I tested both the Array and Non-Array formulas five times and the minimum time for the Array formula was 0.00404 and for the Non-Array it was 0.00402.

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

    Re: Index? Sumproduct?

    So that means the difference between the two is 0.00002 seconds.

    That's a negligible difference and so is the difference shown in my post.

  17. #17
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Index? Sumproduct?

    That means Non-Array formula is doing better than Array formula for the larger data set.

  18. #18
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Index? Sumproduct?

    Moreover when referencing the whole column, Array takes 0.33905 and Non-Array takes 0.33559.

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

    Re: Index? Sumproduct?

    I just tested the formulas on 50,000 rows...

    Lookup values found on row 45,000 although it doesn't matter what row the lookup values are found on. Both formulas evaluate ALL cells referenced.

    Data Range
    E
    F
    G
    H
    I
    J
    K
    1
    test1
    test2
    test3
    test4
    test5
    Average
    2
    Array
    0.03470
    0.03541
    0.02909
    0.03020
    0.02735
    0.031350
    3
    Non-array
    0.03337
    0.02752
    0.03677
    0.03331
    0.03650
    0.033494


    I would consider the difference to be negligible.

  20. #20
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Index? Sumproduct?

    Quote Originally Posted by Tony Valko View Post
    I would consider the difference to be negligible.
    Correct.

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

    Re: Index? Sumproduct?

    Quote Originally Posted by sktneer View Post
    Moreover when referencing the whole column, Array takes 0.33905 and Non-Array takes 0.33559.
    I would consider the difference to be negligible.

+ 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. Replies: 6
    Last Post: 04-30-2014, 02:42 AM
  2. Replies: 5
    Last Post: 04-20-2012, 08:54 AM
  3. Sumproduct(index
    By jw01 in forum Excel General
    Replies: 8
    Last Post: 07-28-2011, 01:38 AM
  4. Index Or Sumproduct
    By Pindacko in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 12-12-2007, 12:08 PM
  5. sumproduct or index
    By tweety127 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-02-2007, 01:15 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