Question

So I have an excel spreadsheet indicator and I am trying to make a SUMIFS statement that will change which column I am selecting from. So I will have the column name on the left and I want to use that as a varying parameter. See the below tables.

TABLE1
        week1  week2 week3
column1  x       x     x 
column2  x       x     x 
column3  x       x     x

TABLE2
Week column1  column2 column3
  1     x        x       x
  1     x        x       x
  1     x        x       x
  2     x        x       x
  2     x        x       x
  2     x        x       x

So in the above tables TABLE2 holds all the data and TABLE1 is basically a sum of the data by week. So I want the SUMIFS to read something like SUMIFS(TABLE2[????], TABLE2[Week], $B$2) But I can't figure out how to get the sum_range part of the SUMIFS to let me pass parameters in. Any tips or ideas on how to do this?

Was it helpful?

Solution

=INDIRECT("TABLE2[" & A3 & "]")

will resolve to TABLE2[column1] (assuming A3 holds the text "column1")

so the indirect function could be put in as your sum_range (tested in excel 2007)

OTHER TIPS

You could use INDEX and MATCH, something like this

=SUMIFS(INDEX(TABLE2,0,MATCH($A3,$A$7:$D$7,0)),TABLE2[Week],B$2)

where A3 contains "column1" and A7:D7 contains the column headers for TABLE2

Here's a SUMPRODUCT formula. I used Sheet1 and Sheet2 instead of tables. You may be able to change the formula to suit your needs.
=SUMPRODUCT(--(Sheet2!$A2 = Sheet1!$B$1:$D$1) * --(Sheet2!B$1 = "week" & Sheet1!$A$2:$A$7), Sheet1!$B$2:$D$7)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top