Calculation Issues

How to Build Dynamic Excel SUMIFS Across Rows and Columns with MMULT

Tauseeq MagsiTauseeq Magsi Nov 10, 2026 870 views

Question details

Build a dynamic array formula to aggregate trial balance values by account or entity across variable monthly periods without using an intermediate calculation sheet.

How to Build Dynamic SUMIFS Across Rows and Columns using MMULT in Excel
Product
Excel
Device & OS
not provided
Scenario
Aggregating complex trial balance data requiring dynamic intersections of both row elements (like GL codes and entities) and column elements (like variable monthly date periods).
Observed behavior
The user needs to construct a cross-tabular sum that dynamically spills using multiple criteria for both axes, rather than manually building static SUMIFS formulas or intermediate calculation sheets.
Before you start

Ensure you are using a version of Excel or WPS Spreadsheet that supports Dynamic Array functions, as formulas like TOROW, TOCOL, SEQUENCE, and MAKEARRAY are essential for these solutions.

Solution 1Recommended

Use MMULT to Aggregate Data Across Rows and Columns

An MMULT-based matrix approach calculates complex criteria spanning both rows and columns in a single, lightning-fast step.

Matrix multiplication (MMULT) is powerful but requires matching array dimensions. You can multiply boolean arrays (True/False converted to 1/0 using the double-unary -- operator) to create multi-condition filters.

To add multiple row criteria (such as filtering by both entity and GL code), simply multiply the row masks together within the formula.

1
Set up the row criterion array

Use the TOROW function to check the target accounts. For multiple criteria, multiply them: ((TOROW(C6:C19)=C27:C29)*(TOROW(A6:A19)=C39)).

2
Set up the column criterion array

Use the TOCOL function to bound the start and end dates of the monthly periods: (TOCOL(E3:M3)>=E24:I24)*(TOCOL(E4:M4)<=E25:I25).

3
Combine using MMULT

Input the full combined formula =MMULT(--((TOROW(C6:C19)=C27:C29)*(TOROW(A6:A19)=C39)),MMULT(--E6:M19,(TOCOL(E3:M3)>=E24:I24)*(TOCOL(E4:M4)<=E25:I25))) into your target output cell.

Use MMULT to Aggregate Data Across Rows and Columns
Performance Benefit: MMULT is considerably faster and shorter than evaluating row-by-row combinations, making it ideal for processing large trial balances.
Advanced Data Analysis

Perform Advanced Matrix Calculations in WPS Spreadsheet

WPS Spreadsheet natively supports advanced matrix and dynamic array functions like MMULT, SEQUENCE, and FILTER, allowing you to seamlessly process complex financial trial balances and datasets.

  1. 1. Open your workbook: Launch WPS Spreadsheet and open your trial balance or financial modeling workbook.
  2. 2. Select the target cell: Click on the primary cell where you want the aggregated matrix results to appear.
  3. 3. Input the array formula: Type your MMULT or MAKEARRAY formula, ensuring your row and column arrays are perfectly aligned.
  4. 4. Execute the calculation: Press Enter to execute the calculation. WPS Spreadsheet will automatically spill the results into the adjacent cells.
Fully compatible with Microsoft Excel XLSX format and complex array formulas.Supports modern dynamic array functions for advanced financial modeling and reporting.Lightweight software that processes heavy data tabulations quickly and accurately.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my MMULT formula return a #VALUE! error?

This usually happens when the dimensions of the matrices being multiplied are incompatible. In MMULT, the number of columns in the first array must exactly match the number of rows in the second array.

Can I add more than two criteria to an MMULT formula?

Yes. You can add more criteria by multiplying additional boolean arrays within the row or column masks, for example, (TOROW(A6:A19)=C39)*(TOROW(B6:B19)=D39). Both criteria must evaluate to TRUE for the data to be included.

What does the double dash (--) mean in Excel array formulas?

The double unary operator (--) coerces boolean TRUE/FALSE values generated by condition checks into numeric 1s and 0s. This is required because mathematical functions like MMULT cannot process raw TRUE/FALSE text values.