Use SUMPRODUCT with Optional Criteria in WPS Spreadsheets
Question details
Create a SUMPRODUCT formula that applies entered criteria and includes all values for any criterion left blank.

- Product
- WPS Spreadsheets or Microsoft Excel
- Device & OS
- not provided
- Scenario
- Sum values in column D while optionally filtering columns B and C using criteria in cells F6 and G6.
- Observed behavior
- The desired formula filters a column when its criterion is entered and leaves that column unrestricted when its criterion cell is blank.
Check that B6:B23 and C6:C23 contain the fields to filter and D6:D23 contains the numeric values to sum. Leave F6 and G6 empty for unrestricted criteria, or enter the values you want to match.
Use SUMPRODUCT with blank-aware criteria
Use this formula to apply either, both, or neither of two filters.
Each IF expression returns 1 when its criterion cell is blank, so that column does not restrict the sum. Otherwise, it compares the column with the entered criterion.
Click an empty cell outside the data and criterion ranges, such as H6.
Type =SUMPRODUCT(IF(ISBLANK(F6),1,($B$6:$B$23=F6))*IF(ISBLANK(G6),1,($C$6:$C$23=G6))*($D$6:$D$23)) and press Enter.
Enter a value in F6 or G6 to filter its corresponding column. Clear either criterion cell to include all values from that column; clear both to sum all values in D6:D23.

Build the SUMPRODUCT formula in WPS Spreadsheets
Use WPS Spreadsheets to sum a numeric range while allowing either criterion cell to be blank.
- 1. Open your worksheet: Open WPS Spreadsheets and choose File > Open to select your workbook.
- 2. Set up the criteria: Use F6 and G6 for the optional criteria and confirm that B6:B23, C6:C23, and D6:D23 contain the matching data.
- 3. Add the formula: Select H6, enter =SUMPRODUCT(IF(ISBLANK(F6),1,($B$6:$B$23=F6))*IF(ISBLANK(G6),1,($C$6:$C$23=G6))*($D$6:$D$23)), and press Enter.
- 4. Try the result: Type or clear values in F6 and G6 to change which records contribute to the total.

Frequently Asked Questions
What happens if both criterion cells are blank?
Both IF expressions return 1, so the formula sums all numeric values in D6:D23 without filtering columns B or C.
Can I filter by just one criterion?
Yes. Enter a value in F6 to filter column B or in G6 to filter column C, and leave the other criterion cell blank.
Why doesn't a cell containing a formula that returns an empty string count as blank?
ISBLANK checks whether the cell is actually empty. For a criterion cell containing a formula that returns an empty string, use F6="" or G6="" in place of the corresponding ISBLANK test.
Can I use different data ranges?
Yes. Replace B6:B23, C6:C23, and D6:D23 with your own filter and sum ranges, but make sure the ranges cover the same number of rows.




