Explanation
The INDEX function looks up values by position. For example, this formula retrieves the value for Acme sales in Jan:
=INDEX(data,1,1)
The INDEX function has a special and non-obvious behavior: when the row number argument is supplied as zero or null, INDEX retrieves all values in the column referenced by the column number argument. Likewise, when the column number is supplied as zero or nothing, INDEX retrieves all values in the row referenced by the row number argument:
=INDEX(data,0,1) // all of column 1
=INDEX(data,1,0) // all of row 1
In the example for formula, we supply the named range “data” for array, and we pick up the column number from H2. For row number, we deliberately supply zero. This causes INDEX to retrieve all values in column 2 of “data’. The formula is solved like this:
=SUM(INDEX(data,0,2))
=SUM({9700;2700;23700;16450;17500})
=70050
Other calculations
You can use the same approach for other calculations by replacing SUM with AVERAGE, MAX, MIN, etc. For example, to get an average of values in the third month, you can use:
=AVERAGE(INDEX(data,0,3))
More than one column or row
To handle return more than one row or column with INDEX, see the approach described here to “dereference” INDEX.
Explanation
This example shows how the SUMIFS function can sometimes be used to “lookup” numeric values, as an alternative to more complicated multi-criteria lookup formulas. This approach is less flexible than more general lookup formulas based on INDEX and MATCH (or VLOOKUP) but it’s also more straightforward since SUMIFS is designed to easily handle multiple criteria. It’s also very fast.
In the example shown, we are using the SUMIFS function to “look up” the price of an item based on the item name, color, and size. The inputs for these criteria are the cells H5, H6, and H7.
Inside the SUMIFS function, the sum range is supplied as the “Price” column in Table1:
Table1[Price]
Criteria are supplied in 3 range/criteria pairs as follows:
Table1[Item],H5 // item
Table1[Size],H6 // size
Table1[Color],H7 // color
With this configuration, the SUMIFS function finds matching values in the “Price” column and returns the sum of matching prices for the specific criteria entered in H5:H7. Because only one price exists for each possible combination of criteria, the sum of the matching price is the same as the sum of all matching prices.
Notes:
- Each combination of criteria must match one result only.
- Lookup values (the sum range) must be numeric.
- SUMIFS will return zero if no match occurs.