Use SUMPRODUCT to Sum by Category and Year in Spreadsheets
Question details
The user needs to sum values for a specific cost category within a specific fiscal year across a two-dimensional data range where SUMIFS cannot be applied.

- Product
- Spreadsheet
- Device & OS
- not provided
- Scenario
- Calculating conditional sums in a complex two-dimensional dataset containing category rows and date columns.
- Observed behavior
- SUMIFS cannot directly evaluate a 2D data range against mixed row and column criteria simultaneously, requiring an alternative formula to achieve the correct sum.
Ensure your column headers contain valid date formats so the YEAR function can extract the correct fiscal year, and verify that your criteria and data ranges are perfectly aligned.
Use the SUMPRODUCT Function
SUMPRODUCT allows for array calculations that evaluate multiple conditions across rows and columns simultaneously, making it ideal for 2D data ranges.
The SUMPRODUCT function natively handles arrays without requiring special keystrokes. By multiplying boolean arrays (True/False converted to 1/0) with the data range, it filters out values that don't meet your criteria.
Click on the cell where you want the total sum for the specific category and year to appear.
Type the formula: =SUMPRODUCT((B3:B22="Design")*C3:CP22*(YEAR(C2:CP2)=2022)) and ensure the ranges match your actual dataset.
Press Enter. The function will evaluate the row condition (Design) and column condition (2022) to return the correct sum.

Use an Array SUM Formula
An alternative method is using the standard SUM function as an array formula to perform the same logical evaluation.
Master Complex Formulas with WPS Spreadsheet
WPS Spreadsheet fully supports advanced array formulas like SUMPRODUCT, SUMIFS, and dynamic arrays, making two-dimensional data analysis seamless and highly efficient.
- 1. Download and Install: Download WPS Office for free from the official website and install it on your device.
- 2. Open your workbook: Launch WPS Spreadsheet and open your existing .xlsx file containing the 2D dataset.
- 3. Apply the formula: Type =SUMPRODUCT into your target cell to trigger the formula assistant.
- 4. Calculate effortlessly: Input your row and column conditions exactly as you would in Excel to get your customized sum.

Frequently Asked Questions
Why does my SUMPRODUCT formula return a #VALUE! error?
This typically happens if the ranges in your arrays do not have the same dimensions, or if text exists in a range where mathematical operations (like multiplication) are being applied.
Can I use SUMIFS instead of SUMPRODUCT for this task?
No, SUMIFS requires the sum range and criteria ranges to be of the exact same size and orientation (e.g., all columns or all rows). It cannot simultaneously cross-reference a row criteria with a column criteria over a 2D sum range.
How do I change the condition to a different category or year?
Simply replace "Design" with your desired category name (e.g., "Marketing") and 2022 with the target year in the formula: =SUMPRODUCT((B3:B22="Marketing")*C3:CP22*(YEAR(C2:CP2)=2023)).
Does WPS Spreadsheet support the YEAR function inside arrays?
Yes, WPS Spreadsheet fully supports the YEAR function within array formulas and SUMPRODUCT, just like Microsoft Excel, allowing you to seamlessly extract years from date headers.




