Reputation: 5243
I have items in a row (item 1, item 2, etc...) and prices for every item in a column, can I write a sophisticated formula which will calculate the total for every person, without manually entering all intersection?
| Name | Total | item 1 | item 2 | item 3 | | |
|--------|---------|--------|--------|--------|-----------------|----|
| John | 2+9+2=13| 1 | 3 | 2 | price of item 1 | $2 |
| Daniel | 0+6+1=7 | 0 | 2 | 1 | price of item 2 | $3 |
| Max | 2+3+0=5 | 1 | 1 | 0 | price of item 3 | $1 |
Link to Google Spreadsheet with the example
Unfortunately, I can't use scripting here, otherwise, it would be a peace of cake :(
Upvotes: 2
Views: 160
Reputation: 1
try:
=ARRAYFORMULA(IF(A2:A="",,
MMULT(HLOOKUP(C1:E1, TRANSPOSE(G2:H), 2, 0)*C2:E,
ROW(INDIRECT("A1:A"&COLUMNS(C:E)))^0)))
or shorter:
=INDEX(IF(A2:A="",,MMULT(1*C2:E, G2:G4)))
Upvotes: 2
Reputation: 27262
For a alternative solution, try:
=ArrayFormula(if(len(A2:A), mmult(--C2:E, G2:G4),))
Upvotes: 1