| A | B | C | D | E | F | G |
--|---------|------------|-------------|-----------|-----------|---------|------------|--
1 | | | 2024 | 2024 | 2024 | | 2024 |
2 | | | Q1 | Q2 | Q3 | | Q1 |
3 | Brand A | Product 1 | 500 | 70 | 60 | | Brand A |
4 | Brand A | Product 2 | 100 | 47 | 300 | | Product 1 |
5 | Brand A | Product 3 | 800 | 21 | 200 | | 500 |
6 | Brand B | Product 1 | 90 | 56 | 150 | | |
7 | Brand C | Product 1 | 45 | 700 | 790 | | |
8 | Brand C | Product 2 | 600 | 400 | 10 | | |
9 | | | | | | | |
In cell G5
I extract the sum
from the table based on multiple column and row criteria using this formula:
=SUMPRODUCT((A3:A8=G3)*(B3:B8=G4)*(C1:E1=G1)*(C2:E2=G2)*(C3:E8))
.
This formula works without any issue.
However, now I want to implement that if one of the cells in Column G
is empty this filter criteria should be ignored when summing up the values.
For example if I leave the cell G4
empty the value should be 1400 because the criteria for Column B
gets ignored and the sum is calculated based on the criteria for Column A
, Row 1
and Row 2
which in the example is 500+100+800 = 1400.
I tried to go with this formula:
=SUMPRODUCT((A3:A8=G3)*IF(G4="";"*";(B3:B8=G4))*(C1:E1=G1)*(C2:E2=G2)*(C3:E8))
However, it returns #VALUE!
error.
How do I need to modify the formula to make it work?