Conditional Sums Using Multiple Criteria

The examples in the preceding section all used a single comparison criterion. The examples in this section involve summing cells based on multiple criteria.

Figure 17-14 shows the sample worksheet again, for your reference. The worksheet also shows the result of several formulas that demonstrate summing by using multiple criteria.

Figure 17-14. This worksheet demonstrates summing based on multiple criteria.

Using And criteria

Suppose that you want to get a sum of the invoice amounts that are past due and associated with the Oregon office. In other words, the value in the Amount range will be summed only if both of the following criteria are met:

  • The corresponding value in the Difference range is negative.

  • The corresponding text in the Office range is “Oregon.”

If you’re using Excel 2007, the following formula does the job:

=SUMIFS(Amount,Difference,"<0",Office,"Oregon")

The array formula that follows returns the same result and will work in all versions of Excel.

{=SUM((Difference<0)*(Office="Oregon")*Amount)}

Using Or criteria

Suppose that you want to get a sum of past-due invoice amounts or ones associated with the Oregon office. In other words, the value in the Amount range will be summed if either of the following criteria is met:

  • The corresponding value in the Difference range is negative.

  • The corresponding text ...

Get Office 2007 Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.