lotusaurus
New Member
I have a table of numeric data, which could be sales; each row represents a combination of two factors (e.g., store type and region) while each column represents a result for a numeric factor, say product code. So I was trying to sum the scores for a particular combination, of store type and region, for particular product codes.
I solved this thorny problem using an extension of what I found in the article here: http://chandoo.org/wp/2011/05/26/advanced-sumproduct-queries/
I used SUMPRODUCT(($A$2:$A$5=$A$9)*($B$2:$B$5=$B$9)*($C$1:$E$1>=$C$7)*($C$1:$E$1<=$C$8),$C$2:$E$5). (The absolute references are just there so that I can easily copy to another cell and play around.)
Now this gives me the answer I want, but I don't understand why it works. In the referenced article, I can understand how the array multiplication works, but it doesn't seem to apply in this case, yet it still works!
My data is a 4 x 3 array. In my SUMPRODUCT, I have, in order, these criteria arrays (4 x 1)*(4 x 1)*(1 x 3)*(1 x 3), which somehow ends up with a 4 x 3 array that multiplies correctly with my 4 x 3 data array. I thought the 4 at the beginning and the 3 at the end were the key, but if I reorder the criteria arrays ("Alternative" in my spreadsheet) to the following: (4 x 1)*(1 x 3)*(1 x 3)*(4 x 1), I still get the correct answer. I also tried (4 x 1)*(1 x 3)*(4 x 1)*(1 x 3) and still got the correct answer.
So my conclusion is that the array multiplication is indeed commutative (if that's the right word) and somehow Excel "collapses" arrays of the same dimensions. This is wonderfully convenient, but I'd like to understand why this approach works.
I solved this thorny problem using an extension of what I found in the article here: http://chandoo.org/wp/2011/05/26/advanced-sumproduct-queries/
I used SUMPRODUCT(($A$2:$A$5=$A$9)*($B$2:$B$5=$B$9)*($C$1:$E$1>=$C$7)*($C$1:$E$1<=$C$8),$C$2:$E$5). (The absolute references are just there so that I can easily copy to another cell and play around.)
Now this gives me the answer I want, but I don't understand why it works. In the referenced article, I can understand how the array multiplication works, but it doesn't seem to apply in this case, yet it still works!
My data is a 4 x 3 array. In my SUMPRODUCT, I have, in order, these criteria arrays (4 x 1)*(4 x 1)*(1 x 3)*(1 x 3), which somehow ends up with a 4 x 3 array that multiplies correctly with my 4 x 3 data array. I thought the 4 at the beginning and the 3 at the end were the key, but if I reorder the criteria arrays ("Alternative" in my spreadsheet) to the following: (4 x 1)*(1 x 3)*(1 x 3)*(4 x 1), I still get the correct answer. I also tried (4 x 1)*(1 x 3)*(4 x 1)*(1 x 3) and still got the correct answer.
So my conclusion is that the array multiplication is indeed commutative (if that's the right word) and somehow Excel "collapses" arrays of the same dimensions. This is wonderfully convenient, but I'd like to understand why this approach works.