Office 2007 Bible
by John Walkenbach, Herb Tyson, Faithe Wempen, Cary N. Prague, Michael R. Groh, Peter G. Aitken, Michael R. Irwin, Gavin Powell, Lisa A. Bucki
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access