+ Reply to Thread
Results 1 to 15 of 15

INDEX MATCH inside of SUMSIF?

Hybrid View

  1. #1
    Registered User
    Join Date
    09-02-2016
    Location
    US
    MS-Off Ver
    2013
    Posts
    50

    INDEX MATCH inside of SUMSIF?

    Can someone please take a look at this sample doc. I put all the information on one sheet in this example but the 3 tables are separate worksheets. I'm trying to generate the numbers that are in yellow from the other two tables. I'm trying to find a way to use the raw date from sheet 1 and have the criteria range know that I'm talking about a specific week number.


    The only thing I can think of (other than a macro) that might work is maybe for the criteria range2, putting in an index match so that it somehow knows how to convert the raw date into the correlating week number.


    This is what I have so far: the ??? represents the criteria range2 where I'm supposed to put the dates from sheet 1.

    =SUMIFS(C3:C10,A3:A10,A14,?????,B13)
    =SUMIFS(C3:C10,A3:A10,A14,INDEX(B3:B10,MATCH(B13,G4:G11,0),MATCH(A14,A3:A10,0)),B13)

    limitations:

    I don't want to manipulate Sheet 1 (add any columns).
    I don't want to use a macro unless this isn't possible via formulas.


    Is there something wrong with my formula or Is there a better way to do this.

    Any thoughts are appreciated.
    Attached Files Attached Files
    Last edited by Questionz; 09-03-2016 at 12:43 PM.

  2. #2
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: INDEX MATCH inside of SUMSIF?

    um, explain where the numbers are coming from, and why they are in different columns.

    The example sheet isn't very self-explanatory. At first, I thought it was simply a sum of all the values for that name, but then I saw tom was 5 up top, and 4 in the yellow box. I also have no idea why some numbers are in week 1 and others are in week 4. Please explain. It looks like we are matching the dates to put them in the correct columns, is that right?

    It doesn't explain how toms 5 becomes a 4 though.

  3. #3
    Registered User
    Join Date
    09-02-2016
    Location
    US
    MS-Off Ver
    2013
    Posts
    50

    Re: INDEX MATCH inside of SUMSIF?

    Thank you greatly for responding and helping me to know how to make things clearer.

    I corrected the table for Tom and Joe. I'm sorry about those typos.

    -Jack is 5 under W1 because he is listed in Sheet 1 with the date 6/15/2016. This date correlates with W1 from sheet 2 (a fixed calendar). That is the only entry for him so the other weeks are 0.
    -Mary is 13 under W1 because she is listed with two dates. Both those dates correlate to W1 so the values 9 and 4 are added.
    -Joe also has two entires in sheet 1, both with different dates that correlate with a different week. He has 8 under W1 and 3 in W2.

    BTW I was using sumsif because if a name occurs more than once for the same week, those values from sheet 1 are added.
    Last edited by Questionz; 09-02-2016 at 09:28 PM.

  4. #4
    Registered User
    Join Date
    09-02-2016
    Location
    US
    MS-Off Ver
    2013
    Posts
    50

    Re: INDEX MATCH inside of SUMSIF?

    I edited my second post with more details to try to make it clearer.

  5. #5
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: INDEX MATCH inside of SUMSIF?

    are your names not going to be entered case sensitive? I am asking because I was going to make named ranges that make unique lists so everything auto-populates.

    For example, you have Mary and mary, and are treating them as the same, will this always be the case, or is this another typo?

  6. #6
    Registered User
    Join Date
    09-02-2016
    Location
    US
    MS-Off Ver
    2013
    Posts
    50

    Re: INDEX MATCH inside of SUMSIF?

    Wow, thanks for looking into it.

    No, it is not case sensitive. (The actual document has names with both letters and numbers but nothing is case sensitive)

  7. #7
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: INDEX MATCH inside of SUMSIF?

    I'm going to use a helper column in sheet 1 because it isn't possible without it, far as I know...(without VBA anyway) You can simply right click the column and hide it.



    I used:

    =A2&"_"&INDEX(Sheet2!$B:$B,MATCH(Sheet1!B2,Sheet2!$A:$A,0))
    for the helper column, all it does is tell which week the respective name is.

    Then I populated the table with this formula:

    =SUMIF(Sheet1!$D$2:$D$9,Sheet3!$A2&"_"&Sheet3!B$1,Sheet1!$C$2:$C$9)
    I also used unique name ranges and stuff to make that part easier for you also. You can see the name ranges by clicking formulas at the top, then going to name manager. I created one called Name and UniqueName. Few formulas and stuff that make them possible. Most notably, the array entered formula:

    =INDEX(Name,MATCH(0,COUNTIF($A$1:A1,Name),0))
    which you can see in the unique name column on sheet3.

    Workbook attached, let me know if any questions, hopefully the helper column doesn't make the workbook irrelevant...
    Attached Files Attached Files
    Last edited by TheN; 09-02-2016 at 11:02 PM.

  8. #8
    Registered User
    Join Date
    09-02-2016
    Location
    US
    MS-Off Ver
    2013
    Posts
    50

    Re: INDEX MATCH inside of SUMSIF?

    using the "_" was a very neat idea! I cut and pasted the helper column into the calendar sheet and it didn't disrupt anything. Thank you for explanation.

  9. #9
    Registered User
    Join Date
    09-02-2016
    Location
    US
    MS-Off Ver
    2013
    Posts
    50

    Re: INDEX MATCH inside of SUMSIF?

    Combining the two cells with (&) first was a neat idea! I was able to cut and paste the helper column to the calendar page and it didn't disrupt anything. Thank youf rthe explanation also.

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,742

    Re: INDEX MATCH inside of SUMSIF?

    Another way ... array-entered in B14 filled down and across
    Formula: copy to clipboard
    =SUM((INDEX($F$4:$F$11,N(IF(1,MATCH(1,1/(B$13=$G$4:$G$11),{0,1}))))=$B$3:$B$10)*($A14=$A$3:$A$10)*$C$3:$C$10)
    If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.

    There were a trailing space in the names A14:A18. I corrected it in the attached.

    If this can be done with SUMIFS I do not see it.
    Attached Files Attached Files
    Dave

  11. #11
    Registered User
    Join Date
    09-02-2016
    Location
    US
    MS-Off Ver
    2013
    Posts
    50

    Re: INDEX MATCH inside of SUMSIF?

    I must say, this is the most intriguing formula I've ever seen. It's probably just advanced. I hope to try to decipher what everything means [(1) the N, 2) How/why you made the IF test and lookup value to be 1, and 3)the usage of / (this isn't really divide is it?)]

    I like how it automatically fills in the data when I add an entry to the yellow area. That's impressive, can you please share how you accomplished that?

    Also, Is there a way to make the columns generic? That is, removing the absolute cell references so that the formula will recognize the entire list if an entry is added to sheet 1 or 2 also? I tried to remove the $'s and make then for example A:A but then I get #NAME error.

    This attachment is updated to hopefully make it easier to see what I'm talking about.

    Thank you for taking the time to look at this.

  12. #12
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,742

    Re: INDEX MATCH inside of SUMSIF?

    I hope to try to decipher what everything means [(1) the N, 2) How/why you made the IF test and lookup value to be 1, and 3)the usage of / (this isn't really divide is it?)]
    I'll attempt to take these one at a time. The N(IF(1, is an array coercion technique. Occasionally (and fortunately it's rare) an array of values will stubbornly refuse to pass on

    anything except the first element of the array. The N(IF(1, strategy forces the whole array to be passed. It all relies upon secondary functions of N and IF. The IF(1, is thought of as a

    tautology. The 1 forces a TRUE. There are other techniques as well. If you would like to know more about these you might find this site of interest.

    https://excelxor.com/category/coerci...ay-of-returns/

    If it does not take you directly to the article click on "Coercing an array of returns".

    The 1/ inside the MATCH function returns an array of {1;1;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!} 1s and #DIV/0! errors. MATCH has the fortunate property of ignoring

    errors in its second argument. The "magic" in this formula is in the 3rd argument of MATCH [match_type]. Ordinarily we use only one value. In this case MATCH can be instructed to

    perform 'double-duty' with both {0,1} match types. Match will simultaneously return the first exact matching 1 in the above array and the last 1 in the same array. If you were to select

    any of the formula cells, select only the above MATCH function in the formula bar and press the F9 function key you would see {1,2} under W1, {3,4} under W2, {5,6} under W3 etc.

    And by-the-way, this formula works like that only because there are no more than two W# in G4:G10. If there were more we would need a different and probably more complicated

    formula.


    I like how it automatically fills in the data when I add an entry to the yellow area. ....... can you please share how you accomplished that?
    That is more or less automatic. Since the formula is referencing absolute ranges while referencing row relative names in A14:A?? and column relative W# in row 13 that part solves itself. Referring to the comment in the last upload grabbing the fill handle and dragging down and then across takes care of this.

    Also, Is there a way to make the columns generic? That is, removing the absolute cell references so that the formula will recognize the entire list if an entry is added to sheet 1 or 2 also? I tried to remove the $'s and make then for example A:A but then I get #NAME error.
    If you need flexibility in those absolute ranges I would suggest making the references a little bit larger than anticipated need. I.E. if you anticipate a maximum range of 200 rows make

    all of the ranges say 250 rows. The main thing you want to avoid is referencing whole columns / rows .... that forces Excel to do math operations on over 1 million rows in

    each copy of the formula. It slows the workbook down. Added to that is the fact that this is an array formula. Array formulas are resource hungry. The whole column / row reference

    magnifies the dilemma.

    Has this helped?

  13. #13
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,742

    Re: INDEX MATCH inside of SUMSIF?

    Questionz,

    Try this much simpler formula. It does not have to be array-entered.
    Formula: copy to clipboard
    =SUMPRODUCT(SUMIFS($C$3:$C$12,$B$3:$B$12,$F$4:$F$11,$A$3:$A$12,$A16),COUNTIF(B$15,$G$4:$G$11))
    It is far more flexible than my former.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    09-02-2016
    Location
    US
    MS-Off Ver
    2013
    Posts
    50

    Re: INDEX MATCH inside of SUMSIF?

    Thank you for helping me with flexibility. Oh yes, I like this sumproduct a lot better... I also appreciate the tips on how to not slow down excel. I hope to still research/understand all that's going on in the array formula because I'll probably need it at some point, but i might not be able to fully absorb it before I need to finish this assignment.

    Question: are you able to put in words the logic behind this please:

    in the COUNTIF, you used a cell for the range, and a range for the criteria. (I tried to switch them but it doesn't work so what you did seems pretty intentional)

    =SUMPRODUCT(SUMIFS($C$3:$C$12,$B$3:$B$12,$F$4:$F$11,$A$3:$A$12,$A16),COUNTIF(B$15,$G$4:$G$11))

    thank you.

  15. #15
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,742

    Re: INDEX MATCH inside of SUMSIF?

    That way of doing COUNTIF breaks down the distribution one-by-one of the counts. Select it, press F9 function key .... {1;1;0;0;0;0;0;0}

    I that was a "left-over" from trying to reconcile rows in the SUMIFS during formula build. I forgot that --(B$15=$G$4:$G$11) is simpler and does just as well. F9ed {1;1;0;0;0;0;0;0}.

    That other formula would be:

    =SUMPRODUCT(SUMIFS($C$3:$C$13,$B$3:$B$13,$F$4:$F$11,$A$3:$A$13,$A16),--(B$15=$G$4:$G$11))

    Sorry for the confusion.

+ 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] Exclude Zero's from Min Function nested inside an index+Match... all within CELL funtion
    By clemsoncooz in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 08-05-2014, 05:16 PM
  2. [SOLVED] Nesting 2 INDIRECT inside an INDEX MATCH - any ideas?
    By Sam the Monster in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-14-2013, 10:25 AM
  3. Index/match problem with Changing Rank - Example inside
    By kamelkid2 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-24-2013, 04:43 AM
  4. Choosing Name Range inside Index / Match Function
    By gallow in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-05-2012, 07:08 AM
  5. String inside Match Index
    By BHudPE in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-23-2010, 01:32 PM
  6. Excel 2007 : using MATCH inside of an INDEX formula
    By can2c in forum Excel General
    Replies: 2
    Last Post: 03-17-2010, 06:37 AM
  7. Index/Match function inside an array
    By tittiot in forum Excel General
    Replies: 2
    Last Post: 01-20-2010, 09:48 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