counting using multiple criteria

G

Guest

Hi,

I have a problem for which I can't seem to find a working solution. On the
one hand I have a vertical table with employee names, the number of years
they have been with the company, and all this sorted by the employee's age
(in years). This table will be updated from time to time, and as such it
doesn't have a fixed length.

On the other hand I have a table which shows the number of employees in a
particular age category (-20, 21-25, 26-30, etc) horizontally, and the number
of years they have been with the company (again in groups: 0-5 yrs, 5-10 yrs,
etc) vertically.

From this table, which is currently being updated manually, one can see that
for example, the company has 8 employees in the category 31 to 35 years, who
have been with the company 0 to 5 years, etc.

Is there a function to count the number of people who match both criteria to
fit into a specific cell of the table?
 
G

Guest

sumproduct() works well for this type of application
=sumproduct(--(and(Agerange>=Age1,Agerange<=Age2),--(and(Servicerange>=time1,Servicerange<=time2))
ther arrays in each section need to be the same size and cannot reference
the shorthand for entire rows or columns.
 
J

Jerry W. Lewis

The standard approach for counting with multiple criteria is
=SUMPRODUCT((criteria1)*(criteria2)*...)
The explicit multiplication coerces the boolean arrays to 0's (FALSE)
and 1's (TRUE), so that the subsequent sum is equivalent to counting.

Jerry
 
B

Bob Phillips

Assuming that your results table is in E1:J7 (F1=0-20, G1=21-25, etc.
E2=0-5,E3-5-10, etc), then use

=SUMPRODUCT((length_of_service>--LEFT($E3,FIND("-",$E3)-1))*(length_of_servi
ce<=--RIGHT($E3,LEN($E3)-FIND("-",$E3)))*(age>=--LEFT(G$1,FIND("-",G$1)-1))*
(age<=--RIGHT(G$1,LEN(G$1)-FIND("-",G$1))))

where length_of_service is the years in the job column, age is the age in
years column.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top