Imagine a dataset as shown below
Status | Text | Number |
Active | bat | 1 |
Passive | erq | 2 |
Passive | cat | 3 |
Active | enm | 4 |
Active | dog | 5 |
Suppose the data is in range A3:C7 (headings are in A2:C2). The objective is to add numbers where the following conditions are met:
1. Status should be Active; and
2. Text should contain either b or c or d
So the result for the dataset above should be 6 i.e. 1+5. Sounding like a simple case of summarising based on multiple conditions, one may attempt using the SUMIFS() function here. However, a single SUMIFS() function will not work because a SUMIFS() can only accept multiple AND conditions (not OR conditions). The only way to make the SUMIFS() function work is to use 3 of them and then add them up.
So this SUMIFS() function will work
=SUMIFS($C$3:$C$7,$A$3:$A$7,A11,$B$3:$B$7,B11)+SUMIFS($C$3:$C$7,$A$3:$A$7,A12,$B$3:$B$7,B12)+SUMIFS($C$3:$C$7,$A$3:$A$7,A13,$B$3:$B$7,B13)
A11:A13 has Active and B11:B13 has *a*,*b*,*c*.
While this looks like a solution, the problem is that there will have to be one SUMIFS() function for each OR condition. So the more the number of OR conditions, the more the SUMIFS() functions and the lengthier the formula.
In this workbook, I have shared two alternative solution. One uses the DSUM() function and other uses a combination of MMULT(), TRANSPOSE() and SUMPRODUCT() functions.
Summarise data with multiple wildcard OR conditions
{ 0 Comments }