I am trying to use SUMIFS to add amounts where the user can optionally enter filtering criteria for multiple columns and where some cells in filtered columns may be blank. The problem is that the total does not include rows where a criteria column is blank when no filtering criteria is entered. I have searched for a solution and implemented one that works in all cases except where no criteria is entered.
For example, the following scenario works: Joe has been entered as criteria for the Person column, nothing has been entered for the Region column and the SUMIFS function (highlighted) returns 8. This includes the two rows where Joe is the Person, regardless of what is in the Region column.
Similarly, if I enter West as the Region and leave Person blank then SUMIFS returns 4, which is also correct.
The problem occurs when I leave both Region and Person blank: SUMIFS returns 9, ignoring rows where Region or Person is blank. It should return 15. Any ideas how to make this work when all criteria are blank?
For example, the following scenario works: Joe has been entered as criteria for the Person column, nothing has been entered for the Region column and the SUMIFS function (highlighted) returns 8. This includes the two rows where Joe is the Person, regardless of what is in the Region column.
Book1 | |||||
---|---|---|---|---|---|
B | C | D | |||
3 | Region | 8 | |||
4 | Person | Joe | |||
5 | |||||
6 | |||||
7 | Region | Person | Amount | ||
8 | West | 1 | |||
9 | East | Mary | 2 | ||
10 | West | Joe | 3 | ||
11 | East | Mary | 4 | ||
12 | Joe | 5 | |||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
D3 | D3 | =SUMPRODUCT(SUMIFS(D8:D12,B8:B12,IF(LEN(C3)=0,{"*",""},C3),C8:C12,IF(LEN(C4)=0,{"*",""},C4))) |
Similarly, if I enter West as the Region and leave Person blank then SUMIFS returns 4, which is also correct.
The problem occurs when I leave both Region and Person blank: SUMIFS returns 9, ignoring rows where Region or Person is blank. It should return 15. Any ideas how to make this work when all criteria are blank?
Book1 | |||||
---|---|---|---|---|---|
B | C | D | |||
3 | Region | 9 | |||
4 | Person | ||||
5 | |||||
6 | |||||
7 | Region | Person | Amount | ||
8 | West | 1 | |||
9 | East | Mary | 2 | ||
10 | West | Joe | 3 | ||
11 | East | Mary | 4 | ||
12 | Joe | 5 | |||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
D3 | D3 | =SUMPRODUCT(SUMIFS(D8:D12,B8:B12,IF(LEN(C3)=0,{"*",""},C3),C8:C12,IF(LEN(C4)=0,{"*",""},C4))) |