Tags: DSUM

Summarise data with multiple wildcard OR conditions


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


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 based on an unknown combination of conditions


Data on the sheet named "Sales Data Master" shows the Territory wise, Show Title wise and Sales man wise forecast and actual data.  One may want to summarise data based on an unknown combination of conditions.  Conditions may be entered as:

1. All three conditions specified
2. No condition specified
3. Only first condition specified
4. Only second condition specified
5. Only third condition specified
6. First and second condition specified
7. First and third condition specified
8. Second and third condition specified

You may refer to two solution workbooks here

1. Faster because data sheet formulas have been Pasted Special as Values - Download
2. Slower because data sheet formulas are retained - Download