Page 300 - Excel 2007 Bible
P. 300

19_044039 ch14.qxp  11/21/06  11:06 AM  Page 257
                                             Yet another way to perform this count is to use an array formula:
                                                 {=SUM((Month=”January”)*(SalesRep=”Brooks”)*(Amount>1000))}
                                             Using Or criteria
                                             To count cells by using an Or criterion, you can sometimes use multiple COUNTIF functions. The following
                                            formula, for example, counts the number of sales made in January or February:
                                                 =COUNTIF(Month,”January”)+COUNTIF(Month,”February”)
                                             You can also use the COUNTIF function in an array formula. The following array formula, for example,
                                            returns the same result as the previous formula:
                                                 {=SUM(COUNTIF(Month,{“January”,”February”}))}
                                             But if you base your Or criteria on cells other than the cells being counted, the COUNTIF function won’t
                                             work. (Refer to Figure 14.2.) Suppose that you want to count the number of sales that meet the following
                                             criteria:
                                                 n Month is January, or
                                                 n SalesRep is Brooks, or
                                                 n Amount is greater than 1000      Creating Formulas That Count and Sum     14
                                             If you attempt to create a formula that uses COUNTIF, some double counting will occur. The solution is to
                                             use an array formula like this:
                                                 {=SUM(IF((Month=”January”)+(SalesRep=”Brooks”)+(Amount>1000),1))}
                                             Combining And and Or criteria
                                             In some cases, you may need to combine And and Or criteria when counting. For example, perhaps you
                                             want to count sales that meet the following criteria:
                                                 n Month is January, and
                                                 n SalesRep is Brooks, or SalesRep is Cook
                                             This array formula returns the number of sales that meet the criteria:
                                                 {=SUM((Month=”January”)*IF((SalesRep=”Brooks”)+
                                                 (SalesRep=”Cook”),1))}
                                             Counting the most frequently occurring entry
                                             The MODE function returns the most frequently occurring value in a range. Figure 14.3 shows a worksheet
                                             with values in range A1:A10 (named Data). The formula that follows returns 10 because that value appears
                                            most frequently in the Data range:
                                                 =MODE(Data)










                                                                                                                      257
   295   296   297   298   299   300   301   302   303   304   305