+ Reply to Thread
Results 1 to 11 of 11

sum index results matching multiple criteria

  1. #1
    Registered User
    Join Date
    07-14-2009
    Location
    Indianapolis, IN
    MS-Off Ver
    Excel 2007
    Posts
    9

    sum index results matching multiple criteria

    Hi,

    I have a spreadsheet schedule that pulls quantities from another spreadsheet's cells. if the part number of the reference row matches the schedule cell's part number (row), and the date of the reference cell row is 2 workdays after that of the schedule cell's column, the quantity is put in the right place in the schedule. that part works. the problem I have is that sometimes there is more than one quantity with the same part number and date (due to the parts belonging to different jobs). when this is the case, only one of the quantities is picked up by the schedule. i want the schedule cells to sum the quantities of the reference file with matching criteria. i also don't want to have to change the reference file at all in order to do this. below is the function that works (besides summing the duplicates). the part after the " " is what i would need to alter.

    HXS is the reference file where D is the part number column, I is the date column, and 5 is the index column referencing the quantity.

    C is the part number column in the schedule
    K is the date row in the schedule

    =IF(ISNA(INDEX(HXS.xls!$D$16:$I$310,MATCH(1,IF(HXS.xls!$D$16:$D$310=$C5,IF(HXS.xls!$I$16:$I$310=WORKDAY(K$2,2),1,IF(HXS.xls!$I$16:$I$310=(K$2)+3,1)))),5))," ",(INDEX(HXS.xls!$D$16:$I$310,MATCH(1,IF(HXS.xls!$D$16:$D$310=$C5,IF(HXS.xls!$I$16:$I$310=WORKDAY(K$2,2),1,IF(HXS.xls!$I$16:$I$310=(K$2)+3,1)))),5)))

    I know there's a lot of info here so let me know if it's confusing. Thanks for the help!
    Last edited by oats; 07-15-2009 at 11:47 AM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: sum index results matching multiple criteria

    Does this work?

    =SUMPRODUCT(--(HXS.xls!$D$16:$D$310=$C5),--(HXS.xls!$I$16:$I$310=WORKDAY(K$2,2)),--(HXS.xls!$I$16:$I$310=(K$2)+3),HXS.xls!$H$16:$H$310)

    this will return 0, if sum is 0 or none are found... which you can format or hide zeros for.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: sum index results matching multiple criteria

    I haven't tested this, but here is a punt

    =IF(ISNA(INDEX(HXS.xls!$D$16:$I$310,MATCH(1,IF(HXS.xls!$D$16:$D$310=$C5,IF(HXS.xls!$I$16:$I$310=WORKDAY(K$2,2),1,IF(HXS.xls!$I$16:$I$310=(K$2)+3,1)))),5))," ",
    SUMPRODUCT((HXS.xls!$D$16:$D$310=$C5)*((HXS.xls!$I$16:$I$310=WORKDAY(K$2,2))+(HXS.xls!$I$16:$I$310=(K$2)+3)),HXS.xls!$H$16:$H$310))

  4. #4
    Registered User
    Join Date
    07-14-2009
    Location
    Indianapolis, IN
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: sum index results matching multiple criteria

    ok maybe i spoke too soon. while the sumproduct did work on the cells with duplicate matches, it doubled all the other quantities that didn't have duplicates. i'm thinking there needs to be an if statement of some sort in the sumproduct
    Last edited by oats; 07-14-2009 at 03:25 PM.

  5. #5
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: sum index results matching multiple criteria

    Quote Originally Posted by oats View Post
    ok maybe i spoke too soon. while the sumproduct did work on the cells with duplicate matches, it doubled all the other quantities that didn't have duplicates. i'm thinking there needs to be an if statement of some sort in the sumproduct
    Try mine,

    =SUMPRODUCT((HXS.xls!$D$16:$D$310=$C5)*((HXS.xls!$I$16:$I$310=WORKDAY(K$2,2))+(HXS.xls!$I$16:$I$310=K$2+3)),HXS.xls!$H$16:$H$310)

    there is a subtle difference.


    Watch the spaces that get inserted
    Last edited by Bob Phillips; 07-14-2009 at 06:15 PM. Reason: Warning re spaces

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: sum index results matching multiple criteria

    Or:

    =SUMPRODUCT(--(HXS.xls!$D$16:$D$310=$C5),((HXS.xls!$I$16:$I$310=WORKDAY(K$2,2))+(HXS.xls!$I$16:$I$310=(K$2)+3)),HXS.xls!$H$16:$H$310)

    The + between the 2 arguments for I16:I310 conditions acts as an OR() statement.

  7. #7
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: sum index results matching multiple criteria

    Quote Originally Posted by NBVC View Post
    Or:

    =SUMPRODUCT(--(HXS.xls!$D$16:$D$310=$C5),((HXS.xls!$I$16:$I$310=WORKDAY(K$2,2))+(HXS.xls!$I$16:$I$310=(K$2)+3)),HXS.xls!$H$16:$H$310)

    The + between the 2 arguments for I16:I310 conditions acts as an OR() statement.
    Isn't that just what I suggested, and had done so from the start?

  8. #8
    Registered User
    Join Date
    07-14-2009
    Location
    Indianapolis, IN
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: sum index results matching multiple criteria

    ok, the sumproduct does pick up duplicates now, but there's a glitch. say the reference file has a friday as the date. that means that the schedule's cells for both tuesday and wednesday will meet the criteria of either 2 workdays or 3 regular days ahead of the reference date (thus putting the quantity in both of the cells instead of just wednesday). i need something that will insert the quantity if it's 2 workdays ahead, but only insert the quantity that's 3 regular days ahead if that regular day happens to be on a weekend.


    =SUMPRODUCT((HXS.xls!$D$16:$D$310=$C5)*((HXS.xls!$I$16:$I$310=WORKDAY(CM$2,2))+(HXS.xls!$I$16:$I$310=K$2+3)),HXS.xls!$H$16:$H$310)

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: sum index results matching multiple criteria

    Probably better if you post a sample workbook showing what you want.

    What if the date is Monday? Workday() function would return Wednesday's date and Date+3 would return Thursday?...

    Not sure I fully understand.

  10. #10
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,697

    Re: sum index results matching multiple criteria

    Try like this

    =SUMPRODUCT((HXS.xls!$D$16:$D$310=$C5)*((HXS.xls!$I$16:$I$310=WORKDAY(CM$2,2))+(HXS.xls!$I$16:$I$310 =K$2+3)*(WEEKDAY(K$2+3,2)>5)),HXS.xls!$H$16:$H$310)

  11. #11
    Registered User
    Join Date
    07-14-2009
    Location
    Indianapolis, IN
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: sum index results matching multiple criteria

    Thank you for suggesting the weekday function, i hadn't thought of that! the formula you gave me resulted in 0's for all the cells though. however, after playing with it a little, i finally found a solution (below). thanks for all the help guys!



    =IF(OR(WEEKDAY(K$2)=4,WEEKDAY(K$2)=5),(SUMPRODUCT((HXS.xls!$D$16:$D$330=$C5)*((HXS.xls!$I$16:$I$330=WORKDAY(K$2,2))+(HXS.xls!$I$16:$I$330=K$2+3)),HXS.xls!$H$16:$H$330)),(SUMPRODUCT((HXS.xls!$D$16:$D$330=$C5)*(HXS.xls!$I$16:$I$330=WORKDAY(K$2,2)),HXS.xls!$H$16:$H$330)))

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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