ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   counting using multiple criteria (https://www.excelbanter.com/excel-discussion-misc-queries/42239-counting-using-multiple-criteria.html)

SyntaX TerroR

counting using multiple criteria
 
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?

bj

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.

"SyntaX TerroR" wrote:

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?


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

SyntaX TerroR wrote:

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?



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)


"SyntaX TerroR" wrote in message
...
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?





All times are GMT +1. The time now is 08:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com