IF Formula

Toastis

Board Regular
Joined
Apr 20, 2011
Messages
65
I have a Hire Date and a Termination Date Column. I need to determine the number of employees that were employed (according to these dates) in January 2011. I will repeat the calculation for Feb, Mar, etc.

The formula would need to include those who may have worked in the month and also been terminated in the same month hired.

Ultimately I need a Starting Headcount for the month and an Ending Headcount for the month.

Those still employed here have a term date of 12/31/2049.

Can anyone help?
<b>Excel 2007</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>N</th><th>O</th><th>P</th><th>Q</th><th>R</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style=";">Driver ID</td><td style=";">Hire Date Only</td><td style=";">Termination Date</td><td style=";">Jan Start</td><td style=";">Jan End </td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style=";">CAUMO01</td><td style="text-align: right;;">01/24/2011</td><td style="text-align: right;;">01/26/2011</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style=";">ADAJU</td><td style="text-align: right;;">09/16/1996</td><td style="text-align: right;;">12/31/2049</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style=";">ADABR</td><td style="text-align: right;;">11/07/2005</td><td style="text-align: right;;">12/31/2049</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style=";">ADAAA</td><td style="text-align: right;;">06/15/2007</td><td style="text-align: right;;">12/31/2049</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style=";">AGUJO</td><td style="text-align: right;;">08/05/2010</td><td style="text-align: right;;">07/19/2011</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style=";">AGUMA</td><td style="text-align: right;;">09/20/1999</td><td style="text-align: right;;">03/18/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style=";">AGUMI</td><td style="text-align: right;;">07/21/2011</td><td style="text-align: right;;">12/31/2049</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">9</td><td style=";">AGURO</td><td style="text-align: right;;">08/15/2007</td><td style="text-align: right;;">12/31/2049</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">10</td><td style=";">AKEHA</td><td style="text-align: right;;">10/11/2002</td><td style="text-align: right;;">12/31/2049</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">11</td><td style=";">ALLRO</td><td style="text-align: right;;">11/18/1998</td><td style="text-align: right;;">12/31/2049</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">12</td><td style=";">ALVJO</td><td style="text-align: right;;">04/04/2008</td><td style="text-align: right;;">12/31/2049</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">13</td><td style=";">ANDGO</td><td style="text-align: right;;">03/09/2007</td><td style="text-align: right;;">05/14/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">14</td><td style=";">ANDJO</td><td style="text-align: right;;">05/22/2006</td><td style="text-align: right;;">04/01/2009</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">15</td><td style=";">ANDMI</td><td style="text-align: right;;">04/03/2000</td><td style="text-align: right;;">02/07/2009</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">16</td><td style=";">ANDRO</td><td style="text-align: right;;">09/15/2007</td><td style="text-align: right;;">12/31/2049</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">17</td><td style=";">ANTJI</td><td style="text-align: right;;">10/20/2010</td><td style="text-align: right;;">12/31/2049</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Sheet1</p><br /><br />
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
One way, try these and copy down:

Q2: =--AND(O2<"1/1/2011"+0,P2>"1/1/2011"+0)
R2: =--AND(O2<"1/31/2011"+0,P2>"1/31/2011"+0)

...and add up the 1s.

Alternately, in any cell:

Jan Start total: =SUMPRODUCT(--(O2:O7<"1/1/2011"+0),--(P2:P7>"1/1/2011"+0))
Jan End total: =SUMPRODUCT(--(O2:O7<"1/31/2011"+0),--(P2:P7>"1/31/2011"+0))

...this way you wouldn't need the helper column, but you only get the totals.
 
Upvote 0
Is this what you're after?

Excel Workbook
ABCDEFGHIJKLMNOPQ
1Driver IDHire Date OnlyTermination Date01/01/201101/02/201101/03/201101/04/201101/05/201101/06/201101/07/201101/08/201101/09/201101/10/201101/11/201101/12/2011
2CAUMO0124/01/201126/01/2011No employed:111010101010111010101010
3ADAJU16/09/199631/12/2049
4ADABR07/11/200531/12/2049
5ADAAA15/06/200731/12/2049
6AGUJO05/08/201019/07/2011
7AGUMA20/09/199918/03/2010
8AGUMI21/07/201131/12/2049
9AGURO15/08/200731/12/2049
10AKEHA11/10/200231/12/2049
11ALLRO18/11/199831/12/2049
12ALVJO04/04/200831/12/2049
13ANDGO09/03/200714/05/2010
14ANDJO22/05/200601/04/2009
15ANDMI03/04/200007/02/2009
16ANDRO15/09/200731/12/2049
17ANTJI20/10/201031/12/2049
Sheet1
 
Upvote 0
One way, try these and copy down:

Q2: =--AND(O2<"1/1/2011"+0,P2>"1/1/2011"+0)
R2: =--AND(O2<"1/31/2011"+0,P2>"1/31/2011"+0)

...and add up the 1s.

Alternately, in any cell:

Jan Start total: =SUMPRODUCT(--(O2:O7<"1/1/2011"+0),--(P2:P7>"1/1/2011"+0))
Jan End total: =SUMPRODUCT(--(O2:O7<"1/31/2011"+0),--(P2:P7>"1/31/2011"+0))

...this way you wouldn't need the helper column, but you only get the totals.

Thanks - This worked as far as I can tell :) Thank you again.
 
Upvote 0
Hi friend can you try this one.

I convert your column heading jan start into date such as 1/1/2011 and january end to 31/1/2011 and for february end to 28/2/2011 and so on up to 31/12/2011.

This is the formula:

For Q2= IF(AND($O2<=Q$1,$P2>=Q$1),1,0) copy down.

For

R2=IF(AND($O2<=R$1,$P2>=R$1),1,IF(AND(MONTH($P2)=MONTH(R$1),YEAR($P2)=YEAR(R$1)),1,0)) copy down and across up to AC17.

Sum each column.

This formula works for ex. hire date 24/1/2011 and termination date 26/1/2011. The employee is counted for January 31, 2011.
 
Last edited:
Upvote 0
Euh njimack's solution falls over if Employee works from e.g. 2 jan 2011 to 31 jan 11. Employee will be counted in jan and feb.

I apologise for me bugging in but I too am looking for a similar way of resolving what the OP is trying.
 
Upvote 0
Euh njimack's solution falls over if Employee works from e.g. 2 jan 2011 to 31 jan 11. Employee will be counted in jan and feb.

I apologise for me bugging in but I too am looking for a similar way of resolving what the OP is trying.

Based on the OP's request, njimack and I both created solutions that function precisely as we intended (can only speak for myself, but guessing here). I agree that they work differently, as pointed out in post #6 - and that they may or may not do what the OP intended...
If someone is looking for help to create a solution that functions differently than both, please post the desired *results* so that it is very clear what is the expectation. :)

Tai
 
Upvote 0
The formula would need to include those who may have worked in the month and also been terminated in the same month hired.

Ultimately I need a Starting Headcount for the month and an Ending Headcount for the month.


Based on the OP's request, njimack and I both created solutions that function precisely as we intended...
Tai

Hi Tai, I agree. I believe I glanced over the second part as quoted above and only concentrated on the 1st part where the employee needed to be counted too if he only worked for part of the same month.

I've been playing around with njimack's solution and got it to work for me.
I report on resources too and count them as positive if they've worked a partial month. :)

Rob
 
Upvote 0
Cool, glad you got it going. Obviously I glossed over the part of post #1 that didn't gel for me right away... Incidentally, I think MrVillareal probably posted what you want, in post #5. He counts a 3-day-long employee at the end of the month when they were hired/fired - *and* he explicitly says that's what he is doing, love it! :)
 
Upvote 0

Forum statistics

Threads
1,224,557
Messages
6,179,508
Members
452,918
Latest member
Davion615

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top