r/excel•
SCMAD

Can I index(match so it functions as a SUMIF with multiple sum lookup values?

solved

This might be a convoluted way of doing this so if you have a better idea please let me know, but right now I have 3 tables. A source table, a selector table, and a consolidated table.

My source table is Source!A2:H22. A2:A22 are my categories. B2:H22 are the data for those categories in each year (Column B is year 1, Column C is year 2, etc). For the sake of this example, let's say these categories are just people's names. So A2 is Brian, A3, is Jessica, A4 is Mike, A5 is Linda, A6 is Tom, A7 is Gary, A8 is Jane, etc.

My selector table is Selector!A2:F22. Cells A2:A22 are empty input cells. The user inputs whatever "new" category he chooses. B2:F22 are data validation cells that pull from A2:A22 of the source table.

The reason for this is that I want to be able to consolidate the 20 rows of source data into broader groups. So in A2 of my selector table I input whatever I choose, in this case it is "On-site Males", and then in B2:F2 I select which of my source categories (names) should be lumped into this new group. So if I know Tom, Gary, and Mike are all working On-site this week, I enter those names into B2, C2, and D2, and leave E2 and F2 blank.

Now the tricky part is the "consolidated table". The first column of my consolidated table are my "new" categories and feeds from my selector table, so A2 of my consolidated table is "On-Site Males". B1, the header cell of column B, is an input cell of my selection. This input could be any of the columns of my source table. For this example, I select "Year 3". What I want to be able to do is have a formula in B2 of my consolidated table that will lookup A2 of my consolidated table (in this case, "On-Site Males") and from there read through my selector table to find "On-Site Males" and the adjacent names in B2:F2 of my selector table. From there I want it to go to the Source table and sum the adjacent names for year 3.

Does this make sense? I can provide more info if needed. This seems like an overly complicated system because of my simplistic example, but in reality, it would be extremely useful.

Edit:

TL;DR

This Picture shows three different tables. The source is static. The selector table allows me to create a group and assign names to it from the source table. In my consolidated table, I want to be able to select a group name in the first column and then in the adjacent columns pick a year. That cell adjacent to the group name will then use the "selector table" to find the individual names in that group and then from there go to the source table and sum the names in that group for the selected year.

It is doing this in the picture because I just manually entered the data. I figure this needs to be some type of combination of index(match to account for the column combined with a SumIFS. Any ideas?

Posted May 15, 2019, 12:33 PM UTC · edited

25
rnelsonee1698•

In this example

=SUM(INDEX($B$2:$D$8,,MATCH(M$1,$B$1:$D$1,0))*MMULT(--($A$2:$A$8=INDEX($G$2:$J$7,MATCH($L2,$F$2:$F$7,0),0)),TRANSPOSE(COLUMN($G$2:$J$7)^0)))

Hit Ctrl+Shift+Enter.

And you may want to learn Pivot Tables as it makes all this very easy to do, no formulas required. Create those two tables (no "2D" tables, each data record gets its own row), add each to Data Model (easy with Power Pivot tab), drag Person to Person to link. Insert -> PivotTable. Drag Type to Rows box, Year to Filters box, allow multiple, remove Year 1, drag Year to Columns box. Drag Value to Values box. Done.

Oh and since I'm harping on doing things the "right way", since gender and location are separate metrics, you could (should) split them up.

2
SCMADOP•

Solution Verified

2
Clippy_Office_AsstMOD•

You have awarded 1 point to rnelsonee

^I ^am ^a ^bot, ^please ^contact ^the ^mods ^for ^any ^questions.

1
SCMADOP•

Thanks so much. I'll look into switching over to pivot tables. The final consolidated table would need to remain as a regular table since it's being linked to Google Slides, but maybe I could do the pivot with the pivot feeding into the consolidated chart

1
BeatNavyAgain228•

Got called into a meeting just as I was finalizing my answer and u/rnelsonee posted while I was gone. Nevertheless, another array formula with CTRL SHIFT ENTER

=SUM(TRANSPOSE(OFFSET($A$1,IFERROR(MATCH(OFFSET($F$1,MATCH($L2,$F$2:$F$5,0),1,1,4),$A$2:$A$8,0),0),MATCH(M$1,$B$1:$D$1,0))))
1