Formula Errors

Excel Formula to Sum a Matrix with Vertical and Horizontal Criteria

Maira MehtabMaira Mehtab Nov 10, 2026 869 views

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).

How to Sum a Matrix Using Vertical and Horizontal Criteria in Excel
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.
Before you start

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).

Solution 1Recommended

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.

1
Select the destination cell

Click on the cell where you want the calculated sum to appear in your standardized table.

2
Enter the array formula

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.

3
Confirm as an array formula

Press Ctrl+Shift+Enter simultaneously to confirm the formula. Excel will automatically enclose the formula in curly braces {}, indicating it is an array formula.

4
Apply to the rest of the table

Copy the cell and paste it down your standardized table to apply the formula to other criteria combinations.

Use an Array Formula with SUM and IF Functions
Dynamic Arrays in Newer Versions: If you have a newer version of Excel (like Microsoft 365 or the latest WPS Office), you may simply press Enter, as dynamic arrays handle this natively without the need for Ctrl+Shift+Enter.
Analyze Data Efficiently

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. 1. Open your workbook: Launch WPS Spreadsheet and open the file containing your matrix data.
  2. 2. Select the cell: Click the target cell where you want your summary calculation.
  3. 3. Input the formula: Type the =SUM(IF(...)) array formula matching your specific row and column criteria.
  4. 4. Calculate: Press Ctrl+Shift+Enter to calculate the result instantly and drag the fill handle to apply it to other cells.
Fully compatible with Microsoft Excel formulas and array calculations.Lightweight and fast, even when processing large data matrices.Free to use with a familiar, tabbed user interface.Built-in dynamic array support for modern data analysis without legacy limitations.
microsoft office alternative - wps office

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.