If you would like to post, please check out the MrExcel Message Board FAQ and register here. If you forgot your password, you can reset your password.
- Forums
- Question Forums
- Excel Questions
- Thread starterkgun12
- Start dateDec 25, 2016
K
kgun12
New Member
- Joined
- Dec 24, 2016
- Messages
- 12
- Dec 25, 2016
- #1
I'm trying to find a way to count all the Male and Female employees for a given date. Below is an example of my data, it's set up with a period start and end, so if the date falls between the range it should count the Male/Female employees. I want to be able to type in the date and have the correct number pop up. If tried to do this a few different ways but at this point I'm stuck. Wanted to sleep on it but decided to register here and see if anyone could help me. I'm sure it's staring me in the face but I just can't get it.
Employee ID | Employee Name | Period Start | Period End | Gender |
30 | Dan | 1/6/2016 | 1/12/2016 | Male |
45 | Karen | 1/6/2016 | 1/12/2016 | Female |
50 | Samantha | 1/6/2016 | 1/12/2016 | Female |
53 | Brenda | 1/6/2016 | 1/12/2016 | Female |
64 | Tom | 1/6/2016 | 1/12/2016 | Female |
32 | John | 1/13/2016 | 1/19/2016 | Male |
27 | Tony | 1/13/2016 | 1/19/2016 | Male |
42 | Mary | 1/13/2016 | 1/19/2016 | Female |
34 | Robert | 1/13/2016 | 1/19/2016 | Male |
<tbody>
</tbody>
Excel Facts
Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Sort by dateSort by votes
Aladin Akyurek
MrExcel MVP
- Joined
- Feb 14, 2002
- Messages
- 85,210
- Dec 25, 2016
- #2
A B C D E F G H I 1 2 1/10/2016 1 4 3 4 5 6 7 8 9 10Row\Col Employee ID Employee Name Period Start Period End Gender male female 30 Dan 1/6/2016 1/12/2016 Male 45 Karen 1/6/2016 1/12/2016 Female 50 Samantha 1/6/2016 1/12/2016 Female 53 Brenda 1/6/2016 1/12/2016 Female 64 Tom 1/6/2016 1/12/2016 Female 32 John 1/13/2016 1/19/2016 Male 27 Tony 1/13/2016 1/19/2016 Male 42 Mary 1/13/2016 1/19/2016 Female 34 Robert 1/13/2016 1/19/2016 Male
In H2 enter and copy to I2...
=COUNTIFS($C$2:$C$10,"<="&$G2,$D$2:$D$10,">="&$G2,$E$2:$E$10,H$1)
Upvote0
K
kgun12
New Member
- Joined
- Dec 24, 2016
- Messages
- 12
- Dec 25, 2016
- #3
Aladin Akyurek said:
Row\Col A
B
C
D
E
F
G
H
I
1
Employee ID Employee Name Period Start Period End Gender male female 2
30 Dan 1/6/2016 1/12/2016 Male 1/10/2016
1
4
3
45 Karen 1/6/2016 1/12/2016 Female 4
50 Samantha 1/6/2016 1/12/2016 Female 5
53 Brenda 1/6/2016 1/12/2016 Female 6
64 Tom 1/6/2016 1/12/2016 Female 7
32 John 1/13/2016 1/19/2016 Male 8
27 Tony 1/13/2016 1/19/2016 Male 9
42 Mary 1/13/2016 1/19/2016 Female 10
34 Robert 1/13/2016 1/19/2016 Male <tbody>
</tbody>In H2 enter and copy to I2...
=COUNTIFS($C$2:$C$10,"<="&$G2,$D$2:$D$10,">="&$G2,$E$2:$E$10,H$1)
Thanks so much!
Upvote0
Aladin Akyurek
MrExcel MVP
- Joined
- Feb 14, 2002
- Messages
- 85,210
- Dec 25, 2016
- #4
kgun12 said:
Thanks so much!
You are welcome.
Upvote0
K
kgun12
New Member
- Joined
- Dec 24, 2016
- Messages
- 12
- Feb 16, 2017
- #5
Some of the employees have started to work on multiple projects during a given work period, so they may get counted twice using the previous formula. Now I could probably just remove duplicated rows, but what would I need to do in order to ignore a duplicates without removing any data?
Upvote0
Aladin Akyurek
MrExcel MVP
- Joined
- Feb 14, 2002
- Messages
- 85,210
- Feb 17, 2017
- #6
kgun12 said:
Some of the employees have started to work on multiple projects during a given work period, so they may get counted twice using the previous formula. Now I could probably just remove duplicated rows, but what would I need to do in order to ignore a duplicates without removing any data?
A B C D E 1 2 3 4 5 6 7 8 9 10 11Row\Col Employee ID Employee Name Period Start Period End Gender 30 Dan 1/6/2016 1/12/2016 Male 45 Karen 1/6/2016 1/12/2016 Female 50 Samantha 1/6/2016 1/12/2016 Female 53 Brenda 1/6/2016 1/12/2016 Female 64 Tom 1/6/2016 1/12/2016 Female 50 Samantha 1/8/2016 1/11/2016 Female 32 John 1/13/2016 1/19/2016 Male 27 Tony 1/13/2016 1/19/2016 Male 42 Mary 1/13/2016 1/19/2016 Female 34 Robert 1/13/2016 1/19/2016 Male
Given the above data, would the female count on 1/10/2016 still be 4. Is this what you mean?
Upvote0
K
kgun12
New Member
- Joined
- Dec 24, 2016
- Messages
- 12
- Feb 17, 2017
- #7
Yes it would, Samantha would only be counted once, so you would only have 3.
Upvote0
Aladin Akyurek
MrExcel MVP
- Joined
- Feb 14, 2002
- Messages
- 85,210
- Feb 17, 2017
- #8
kgun12 said:
Yes it would, Samantha would only be counted once, so you would only have 3.
Actually 4 instead of 5 for Samantha would count once...
A B C D E F G H I 1 2 1/10/2016 1 4 3 4 5 6 7 8 9 10 11Row\Col Employee ID Employee Name Period Start Period End Gender male female 30 Dan 1/6/2016 1/12/2016 Male 45 Karen 1/6/2016 1/12/2016 Female 50 Samantha 1/6/2016 1/12/2016 Female 53 Brenda 1/6/2016 1/12/2016 Female 64 Tom 1/6/2016 1/12/2016 Female 50 Samantha 1/8/2016 1/11/2016 Female 32 John 1/13/2016 1/19/2016 Male 27 Tony 1/13/2016 1/19/2016 Male 42 Mary 1/13/2016 1/19/2016 Female 34 Robert 1/13/2016 1/19/2016 Male
In H2 control+shift+enter, not just enter, and copy across to I2...
=SUM(IF(FREQUENCY(IF(ISNUMBER($A$2:$A$11),IF($C$2:$C$11<=$G2,IF($D$2:$D$11>=$G2,IF($E$2:$E$11=H$1,$A$2:$A$11)))),$A$2:$A$11),1))
Upvote0
M
Mathias Pedersen Heinze
New Member
- Joined
- Jul 7, 2015
- Messages
- 44
- Feb 17, 2017
- #9
I realize this problem has already been solved quite elegantly. However, if you’re interested in a non-array formula solution, here’s an alternative:
=SUMPRODUCT(--($G$2>=$C$2:$C$11),--($G$2<=$D$2:$D$11),--($H1=$E$2:$E$11),1/COUNTIF($A$2:$A$11,$A$2:$A$11))
Upvote0
Aladin Akyurek
MrExcel MVP
- Joined
- Feb 14, 2002
- Messages
- 85,210
- Feb 17, 2017
- #10
Mathias Pedersen Heinze said:
I realize this problem has already been solved quite elegantly. However, if you’re interested in a non-array formula solution, here’s an alternative:
=SUMPRODUCT(--($G$2>=$C$2:$C$11),--($G$2<=$D$2:$D$11),--($H1=$E$2:$E$11),1/COUNTIF($A$2:$A$11,$A$2:$A$11))
While it requires just enter for confirmation, it's an array-processing formula and not very efficient.
See: https://www.mrexcel.com/forum/excel-questions/292473-performance-formulas-unique-count.html
Upvote0
You must log in or register to reply here.
Similar threads
S
- Question
Pull data from sheet to new sheet based on multiple criteria from another sheet in excel
- sallam Qasem
- May 16, 2024
- Excel Questions
- Replies
- 2
- Views
- 155
May 16, 2024
sallam Qasem
S
A
- Question
Lookup+sum+max
- aarky
- Jul 8, 2023
- Excel Questions
- Replies
- 2
- Views
- 433
Jul 8, 2023
aarky
A
M
- Question
HELP IDENTIFY ORIGINAL START DATE BASED ON CONTINOUS SERVICE RULES
- mrshuck
- Nov 10, 2023
- Excel Questions
- Replies
- 0
- Views
- 413
Nov 10, 2023
mrshuck
M
H
- Solved
Change gender and modify some words accordingly.
- harzer
- Jul 18, 2023
- Excel Questions
- Replies
- 5
- Views
- 523
Jul 18, 2023
harzer
H
I
- Question
Tracking vacation requests
- itzzjason
- Jan 26, 2024
- Excel Questions
- Replies
- 9
- Views
- 626
Jan 30, 2024
KRice
K
Forum statistics
- Threads
- 1,217,553
- Messages
- 6,137,251
- Members
- 450,053
- Latest member
- KRSOne
Share this page
- Forums
- Question Forums
- Excel Questions