Excel Formula to Sum a Matrix with Vertical and Horizontal Criteria
Question details
The user wants to calculate the sum of values from a data matrix based on multiple criteria, specifically combining row criteria (e.g., Name) and column criteria (e.g., Date and Plan).

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Extracting and summarizing data from a complex matrix into a standardized table format using multiple intersecting conditions.
- Observed behavior
- Needs a formula that can evaluate both vertical and horizontal headers simultaneously to find and sum the correct intersecting values.
Ensure your matrix data has clear, consistent headers for both rows and columns, and verify whether your version of Excel supports dynamic arrays automatically or requires legacy array entry (Ctrl+Shift+Enter).
Use an Array Formula with SUM and IF Functions
Apply a nested IF inside a SUM function to filter the matrix based on concatenated column and row criteria.
This approach uses nested IF functions to evaluate both column headers (e.g., Date and Plan) and row labels (e.g., Name). When the conditions are met, the formula returns the corresponding values from the matrix; otherwise, it returns FALSE. The SUM function then totals these matching values.
If you are using legacy versions of Excel, you must enter this as an array formula using Ctrl+Shift+Enter. In newer Excel versions with dynamic array support, a standard Enter will work.
Click on the cell where you want the calculated sum to appear in your standardized table.
Type the formula structure combining SUM and IF: =SUM(IF($B$1:$G$1&$B$2:$G$2=$J1&$K1,IF($A$3:$A$7=$L1,$B$3:$G$7))). Adjust the cell references to match your specific matrix boundaries and criteria cells.
Press Ctrl+Shift+Enter simultaneously to confirm the formula. Excel will automatically enclose the formula in curly braces {}, indicating it is an array formula.
Copy the cell and paste it down your standardized table to apply the formula to other criteria combinations.

Use the SUMPRODUCT Function as an Alternative
Use SUMPRODUCT to multiply boolean arrays and sum the matrix without requiring legacy array confirmation.
Master Complex Formulas with WPS Spreadsheet
WPS Spreadsheet offers full compatibility with advanced array formulas, making it easy to summarize and analyze complex matrix data using SUM, IF, SUMPRODUCT, and dynamic arrays.
- 1. Open your workbook: Launch WPS Spreadsheet and open the file containing your matrix data.
- 2. Select the cell: Click the target cell where you want your summary calculation.
- 3. Input the formula: Type the =SUM(IF(...)) array formula matching your specific row and column criteria.
- 4. Calculate: Press Ctrl+Shift+Enter to calculate the result instantly and drag the fill handle to apply it to other cells.

Frequently Asked Questions
Why does my array formula show a #VALUE! error or return zero?
If you are using a legacy version of Excel, you must press Ctrl+Shift+Enter after typing the formula. If you only press Enter, the software will not treat it as an array formula, which often results in a #VALUE! error or an incorrect zero.
Can I use SUMIFS to sum a matrix with both row and column criteria?
The standard SUMIFS function only works with one-dimensional ranges (either a single column or single row for the sum_range). Because your data is in a two-dimensional matrix, you must use an array formula like SUM and IF, or the SUMPRODUCT function.
How do I adjust the formula if my matrix size increases?
You need to update the absolute references in your formula (e.g., changing $B$3:$G$7 to $B$3:$Z$100) to cover the new data range. Ensure that the criteria ranges (like the headers and row labels) are also updated to match the exact dimensions of the new matrix.




