How do I find the total working hours of the below driver?
Duty code Dep.Time Arri.Time
A001 03:35 04:20
A001 04:35 05:20
A001 05:51 06:20
A001 06:40 07:20
A001 09:40 10:20
Total Working Hour: 10:20-03:35 = 06:45hrs
Is there a formula to find the total working hours of a single person or a single duty card?
If you only have one Duty Code as in the example, you can use the MAX and MIN functions to calculate the total hours.
If you have more than one Duty Code, you can use MAXIFS and MINIFS.
Related
I have an Excel Spreadsheet that contains multiple columns. There are two that are of primary interest.
[SAMPLE DATA]
Date & Start Time (BST) | # students
19/05/2021 09:00 | 67
19/05/2021 09:00 | 26
19/05/2021 14:00 | 9
19/05/2021 15:00 | 153
These are "Date and Time" and "Number of People".
I need to be able to add the Number of People for a specific Date and Time and split them into Morning and Afternoon.
[DESIRED RESULTS]
19/05/2021 Morning | 93
19/05/2021 Afternoon | 162
I don't know Excel very well, but I'm assuming that there are formulae that could accomplish this task. Could somebody let me know how this is done?
Thanks for the input, but I couldn't get the expected answers using them, but I found that a Pivot table did the trick.
I have a Dataframe like this:
Hours Person
10 Jack
20 Louis
10 Jack
30 Anne
10 Anne
And I want to represent this data as a pie chart where 50% of the hours belongs to Anne, 25% to Jack an 25% to Louis. I have tried with goupby but it doesn´t represent what I want.
Try:
df.groupby('Person')['Hours'].sum().plot.pie(autopct='%.2f')
Output:
The goal is to fix a circular reference in my logic in this "two weeks pay" input workbook.
It's a temporary sheet for when people are outside the office and can't access the system.
That said, that sheet still should give them accurate data.
There's 26 sheets that contains the times done by an employee for example, in a typical format, for 2 weeks in each (a year in total).
Stripped of all formatting and non-useful information for this enquiry, they would look somewhat like this (with proper dates) :
+-----------+----------+--------+----------+--------+-------+------+
| Date | AM start | AM end | PM start | PM end | total | over |
+-----------+----------+--------+----------+--------+-------+------+
| Monday | 8:00 | 12:00 | 13:00 | 16:00 | 7:00 | 0:00 |
+-----------+----------+--------+----------+--------+-------+------+
| Tuesday | 8:00 | 12:00 | 13:00 | 15:00 | 6:00 | 0:00 |
+-----------+----------+--------+----------+--------+-------+------+
| Wednesday | 8:00 | 12:00 | 13:00 | 17:00 | 8:00 | 1:00 |
+-----------+----------+--------+----------+--------+-------+------+
| ... | .... | .... | .... | .... | .... | .... |
+-----------+----------+--------+----------+--------+-------+------+
Then on another sheet, there's some calculation has to what is the paid amount (maximum 70 hours per 2 weeks), the overtime done that has to be paid, etc.
A B C D E F G
+-------+------------+----------+---------------+-----------------------+-------+---------------------+
1 | Pay # | Hours paid | Overtime | Used overtime | Total hours worked | | Total overtime left |
+-------+------------+----------+---------------+-----------------------+-------+---------------------+
2 | 1 | 70:00 | 5:00 | 0:00 | 75:00 | | 0:00 |
+-------+------------+----------+---------------+-----------------------+-------+---------------------+
3 | 2 | 70:00 | 0:00 | 5:00 | 65:00 | | |
+-------+------------+----------+---------------+-----------------------+-------+---------------------+
4 | ... | ... | ... | .... | | | |
+-------+------------+----------+---------------+-----------------------+-------+---------------------+
In the above table, the pay #2 got 70 hours paid, but the person would have done only 65 hours and used 5 hours of the overtime done the past two weeks.
A1:E4 is connected together, G1:G2 is data by itself, not linked to the pay numbers or other data in that sheet (in other words, there is only one cell that contains that total overtime left and F is used to separate both tables).
G2 currently have 0:00 because the 5:00 it would have had has been used to complete the second pay.
The Hours paid cell (B) contains this formula :
=IF($E$2>=2.91666666666667,2.91666666666667,IF((2.91666666666667- $E$2)<=$G$2;2.91666666666667,$E$2+$D$2))
Step 1 [condition] : If the total hours worked for that two weeks is greater than or equals to 70 hours (the 2.91666666666667 is used here instead of "70:00" to make the comparison works);
Step 1.1 [true] : Then put "70:00" in the cell because there's a 70 hours maximum per two weeks (this is fine since we have another cell that stores the overtime done (in this example, C));
Step 1.2 [false->condition] : Else, the total hours worked for that two weeks is lower than 70 hours so check if 70 hours minus the total hours worked for that two weeks is lower than the total overtime left to be used (used to check if there's overtime left that can be used this time to make the pay the highest it can be up to a maximum of 70 hours);
Step 1.2.1 [true] : If it is, put 70 hours because we'll use some of the overtime left to be paid to complete this two weeks;
Step 1.2.2 [false] : Otherwise, put the total hours worked for that two weeks added to the used overtime for that week (this cell is explained later with her formula and this step is for when there's overtime left, but not enough to make it go up to 70 hours so we put the amount of time it ends up being).
The important part here is to remember that B needs D, hence why I explained it's formula.
The Overtime (C) and "Total hours worked" (E) cells contains basic formulas that either gives the amount of time over 70 hours or the total hours worked; no need to explain it here, it works.
The Used overtime cell (D) is where it gets tricky. To explain it, we'll need to know what's up with G2.
The Total overtime left cell (G2) is the total of overtime hours minus the sum of all cells in D (used overtime).
It's purpose is to get an up to date value of how much overtime there is left to be paid.
Back to Used Overtime.
You probably start to see circular reference here; D needs G2 to work and G2 is the sum of all cells in D (in the table range, not all of them).
The formula requires the notion of how much overtime there is left so it can check if we can use some.
Here's the formula :
=IF($E$2>=2.91666666666667,"00:00",IF((2.91666666666667-$E$2)<=$G$2,(2.91666666666667-$E$2),IF(($G$2+$E$2)<=2.91666666666667,$G$2,"00:00")))
Step 1 [condition] : If the total hours worked for that two weeks is greater than or equals to 70 hours;
Step 1.1 [true] : Then put 0 hours since that pay is already at the 70 hours maximum;
Step 1.2 [false->condition] : Else, the total hours worked for that two weeks is lower than 70 hours and could grow higher if we still have overtime to be paid so check if 70 hours minus the total hours worked for that two weeks (the amount of time we could add from the overtime left) is lower than or equals to the total overtime left to be paid;
Step 1.2.1 [true] : Then put 70 hours minus the total of hours worked for that two weeks (the amount of time we will add from the overtime left to make this pay grows to the maximum of 70 hours);
Step 1.2.2 [false->condition] : Otherwise, check if the total overtime left added to the total of hours worked for that two weeks is lower than or equals to 70 hours (if so, then it means that we can add all the overtime left here without getting over 70 hours);
Step 1.2.2.1 [true] : If it is then the value is the total overtime left since it will make the total hours worked for that two weeks still be under the maximum yet pay for the overtime that was left to be paid;
Step 1.2.2.2 [false] : Otherwise, put 0 hours since we will not be adding overtime to this pay because there is no overtime left to be added.
How could I both have the accurate overtime left and yet have the used overtime both dynamically calculating themselves without a circular reference ?
What if every row had an up to date value for Total Overtime Left after that pay period?
Formula for G2: =C2-D2
Then every G cell after that only needs to add the Overtime Left from the previous pay period + overtime - used overtime:
G3: =G2+C3-D3
And it just goes on from there.
EXCEL - 1st row example; clocked IN at 08:20 - clocked OUT at 17:03
What I want to do is basically in 8:00-8:59 - if row 1 was between them times then output a 1, if not, then output a 0
Any help is greatly appreciated
Assuming 08:00-08:59 is in cell J1, then you can put this formula into J2:
=IF(AND($A2>=VALUE(LEFT(J$1,FIND("-",J$1)-1)),$A2<=VALUE(RIGHT(J$1,LEN(J$1)-FIND("-",J$1)))),1,0)
Storing the time parameters as text forces the use of the VALUE function. Shifting everything down a row and putting the start of the hour in row 1 and the end of the hour in row 2 so it looks like this:
08:00 09:00 10:00 11:00 12:00
Clock1 C1 Clock2 C2 Clock3 C3 Clock4 C4 08:59 09:59 10:59 11:59 12:59
08:20 I 17:03 X
10:20 I 16:03 X
08:00 I 18:00 O
10:11 I 17:00 O
Would change the formula to:
=IF(AND($A3>=J$1,$A3<=J$2),1,0)
I have data as below:
amos 50 10/16/2012 10:13
amri 50 1/9/2013 9:31
andi 10 3/11/2008 10:35
andik 10 12/6/2012 16:58
anggoro 50 9/13/2012 16:14
ari_prabowo 50 11/26/2012 10:30
astra_permana 10 8/2/2010 17:40
atang 10 1/16/2009 14:39
I want to counting how many times such like year of "2008", "2009", "2010", "2012", "2013" occurred.
Thanks for re-formatting your data.
I would add a helper column to calculate the year
=YEAR($A$1)
Then you can use a countif on that column
=COUNTIF($B$1:$B$10,2008)
Otherwise you could use a sumproduct (Excel 2003)
=SUMPRODUCT(($A$1:$A$10>=DATE(2008,1,1))*($A$1:$A$10<DATE(2009,1,1)))
Or countifs (excel 2007 +)
=COUNTIFS($A$1:$A$10,">=1/1/08",$A$1:$A$10,"<1/1/09")