how to calculate overtime in excel using by weekly pay? - excel

+-----------+-----------+------+
| Day | Reg.Hours | OT |
+-----------+-----------+------+
| Monday | 8 | 0.75 |
| Tuesday | 8 | 0.5 |
| Wednesday | 8 | 1 |
| Thursday | 8 | 0 |
| Friday | 8 | 2.25 |
| Saturday | 0 | 0 |
| Sunday | 0 | 0 |
| Monday | 8 | 0 |
| Tuesday | 5.5 | 0 |
| Wednesday | 8 | 3.25 |
| Thursday | 8 | 2.75 |
| Friday | 8 | 0.5 |
| Saturday | 0 | 0 |
| Sunday | 0 | 0 |
+-----------+-----------+------+
Rules are:
Monday to Sunday, at least, work 40 Reg.Hours to get any overtime for that week.
In the above data set for the 2nd week Monday to Sunday for Reg.Hours total is 37.5 that means, the company will deduct 2.5 OT hours from the 2nd week of Monday to Sunday OT hours.
How do I calculate in Excel with a formula for calculating both weeks OT in 1 excel formula?
Let's say per hour pay is $30.00

You could do this with an Array Formula, but as you only have the days of the week, not the actual dates (which are unique) in your table, I think this will be easier with a helper column.
Assuming the first 3 columns are A, B, and C I would add a helper column in column D, starting with D2 and copied down as follows:
=IF(A2="Sunday",MAX(0,SUM(OFFSET(B2,-6,0,7,2))-40),"")
What this does is: Once a week (on Sunday, at the end of the week), Excel will sum up the previous 7 days of data, including column B & C. This is the total number of hours worked. That amount, minus 40 [limited to 0, if < 40 hours are worked], represents the total number of OT hours worked that week.
The fact that you have a regular hours column and an OT column is a bit of a red herring - instead of checking whether any OT was worked on any day, and then subtracting by the number of regular hours NOT worked on other days, just compare the whole week's work to 40 and end the calculation there.

I think the easiest way would be to use a iamge to demonstrate the answer

Assuming Day is Column A, Row 1, Regular is Column B, Row 1, and OT is Column C, Row 1:
First, Calculate total regular and OT hours for each week in the pay period:
Col. A Col. B Col. C
On Row 17, Calculate Regular/OT Hours: Week 1 =SUM(B2:B8) =SUM(B9:C15)
On Row 18, Calculate Regular/OT Hours: Week 2 =SUM(C2:C8) =SUM(C9:C15)
On Row 19, Calculate:
Regular Hours =IF(B17+C17>=40,40,B17+C17)+IF(B18+C18>=40,40,B18+C18)
OT Hours =IF(B17+C17>=40,B17-40+C17,0)+IF(B18+C18>=40,B18-40+C18,0)
Hope this helps.

Related

How to add a point to a cell when the difference of a date is < 45 days in a range of cells

I have an excel spreadsheet where there is a start date and an end date. When a person closes a ticket in less than 45 days (the difference between the start date and the end date is <45days) they are awarded 0.5 points. They also need to be sorted by month. So dates in 11 would be allocated to the points in the November column. Here is what I have so far but is not working.
=SUM(IF(AND(MONTH(I2:I1000)=11)DATEDIF(I2:I1000,J2:J1000,"D")<=45,0.5,0)
I have tried a normal IF function as well but it doesnt seem to add properly when the ranges of cells are added.
| Start Date | End Date | November Points | December Points | |
|------------|------------|-----------------|-----------------|---|
| 11/12/2019 | 11/28/2019 | 1.0 | | |
| 12/1/2019 | 1/05/2019 | | 0.5 | |
| 11/12/2019 | 11/30/2019 | | | |
So here you can see when the start date is 11/12/2019 and the end date is 11/28/2019 0.5 points is added to the November Points cell(the total in that cell is 1.0 since there are 2 date ranges within 45 days for November). When the start date is 12/1/2019 to end date 1/05/2019 there is now 0.5 points in the December cell.
This might work:
| - | B | C | D | E | F | G |
|---|------------|------------|------|-----------------|-----------------|----------------|
| 2 | Start Date | End Date | Days | November Points | December Points | January Points |
| 3 | 12/11/2019 | 28/11/2019 | 16 | | | |
| 4 | 01/12/2019 | 05/01/2020 | 35 | | | |
| 5 | 12/11/2019 | 30/11/2019 | 18 | | | |
| 6 | | | | 1 | 0.5 | 0 |
Formula and formatting used:
Cell E2: 01/11/19 (or 11/01/19 in USA) and give the cell a custom number format of mmmm "Points" - do this for F2 & G2.
Column D: =DATEDIF(B3,C3,"d")
Totals in row 6: =COUNTIFS($D$3:$D$5,"<=45",$B$3:$B$5,">=" & E$2,$B$3:$B$5,"<" & F$2)/2
So the COUNTIFS will count how many days are <=45, will check that the dates in column B are >= 1st of the month, will check that the dates in column B are < 1st of the following month.

How to get the week number for day irrespective of the calender week number?

how to get the week number for the day irrespective of the calender week in excel?
Iam looking for the column "nth_week_number" .In the below table "2/5/2018" will fall in the 2nd week of the Feb 2018 but It was a 1st Monday of that Month.
Someone please help to resolve this in excel.
| Date | Weekday | week _of_the_month | nth_week_number |
|-----------|-----------|--------------------|-----------------|
| 2/1/2018 | Thursday | 1 | 1st Thrusday |
| 2/2/2018 | Friday | 1 | 1st Friday |
| 2/3/2018 | Saturday | 1 | 1st Saturday |
| 2/4/2018 | Sunday | 2 | 1st Sunday |
| 2/5/2018 | Monday | 2 | 1st Monday |
| 2/6/2018 | Tuesday | 2 | 1st Tuesday |
| 2/7/2018 | Wednesday | 2 | 1st Wednesday |
| 2/8/2018 | Thursday | 2 | 2nd Thrusday |
| 2/9/2018 | Friday | 2 | 2nd Friday |
| 2/10/2018 | Saturday | 2 | 2nd Saturday |
| 2/11/2018 | Sunday | 3 | 2nd Sunday |
| 2/12/2018 | Monday | 3 | 2nd Monday |
| 2/13/2018 | Tuesday | 3 | 2nd Tuesday |
Try this formula in row 2 and copy it down:
=(ROUNDUP(DAY(A1)/7;0)&". "&TEXT(A1;"dddd"))
This will output 2. Thursday for example, formatting it as 1st, 2nd, 3rd, etc. would require a bit more work. Please note that you might have to change the semicolons ; to regular commas , in an English version of Excel (I think).
Edit: Updated formula to fit your exact case, as suggested by #Ron Rosenfeld:
=(CHOOSE(ROUNDUP(DAY(B1)/7;0);"1st ";"2nd "; "3rd "; "4th "; "5th ")&TEXT(B1;"dddd"))

No of days between 2 dates

In the sample data I have employee wise tour dates with month break up sorted by dates in ascending order. I would like to calculate days. Any formula suggestion please?
Conditions:
1. 1 date for 1 month and 1 employee
2. Should include start date also.
From the below example I may explain my requirement for one employee no.1531. All my dates are in DD/MM/YYYY format.
| 1531 | 3-4-2018 | 3-4-2018 | 4 |
| 1531 | 3-4-2018 | 4-4-2018 | 4 |
| 1531 | 3-4-2018 | 7-4-2018 | 4 |
| 1531 | 22-4-2018 | 2-5-2018 | 4 |
| 1531 | 3-5-2018 | 4-5-2018 | 5 |
| 1532 | 1-4-2018 | 2-4-2018 | 4 |
| 1532 | 22-4-2018 | 2-5-2018 | 4 |
| 1532 | 3-5-2018 | 4-5-2018 | 5 |
1531 employee were started his tour on 03/04/2018 and concluded on the same day for one location. Again he started on the same day 03/04/2018 and concluded on 04/04/2018 for 2nd location. Again the person mentioned he started on 03/04/2018 and concluded on 07/04/2018 for another location. In the above said the date 03/04/2018 were entered trice which was not right, but because I don't have control to stop this in application the entries were made by employee wrongly. So I want excel to consider the date 03/04/2018 as one time only while calculating days. I was tried my best to arrive the days but could not. I have attached my formula as separate file for your kind reference. Kindly look into this and give solution. Even this formula i got through from one among the stack overflow member only. In this i was not comfortable to get my dynamic starting date.
I have asked the similar question earlier also but i have not received any answer against my expectations
Try to do Date 1 - Date 2. Most libraries in most languages should have the - operator overridden.
If not, convert both dates to epoch timestamps(seconds) and then divide it by (24*60):
Date Date1 = new Date(03/04/2018);
Date Date2 = new Date(04/04/2018);
int days = (Date2.toTimeStamp() - Date1.toTimeStamp()) / (24*60);

Calculate total hours between cell like 9-5?

I'm looking to create a shift schedule sheet for my team. This is what I've got so far:
How do I calculate the total hours for the 7 days in between those times?
Thanks
How about splitting starting time and end time in two columns such as:
| Monday | Tuesday | ...
| 9am | 5pm | 9am | 5pm | ...
Then if you do an arithmetic operation, you'll have a result in days. So simply multiply by 24:
1 | A | B | C | D |
2 | Monday | Tuesday | ... |
3 | 9am | 5pm | 9am | 5pm | ... | =24*( (B3-A3) + (D3-C3) ...)
Tested in Excel 2013:
Provided that A3, B3, C3... are times. Formatting is up to you obviously.

How do I find the max & min values of multiple groups in an Excel?

I know about the Pivot-table, but I need summary data in display. That means that I'm also doing other datagathering and Pivot just won't do.
My table looks something like this:
Date | Value | Weekday
1.1. | 5903 | Thursday
2.1. | 2981 | Friday
5.1. | 3046 | Monday
6.1. | 5021 | Tuesday
7.1. | 6785 | Wednesday
8.1. | 5074 | Thursday
9.1. | 3631 | Friday
12.1.| 7083 | Monday
13.1.| 3531 | Tuesday
14.1.| 5589 | Wednesday
15.1.| 2068 | Thursday
16.1.| 6485 | Friday
19.1.| 7013 | Monday
20.1.| 3802 | Tuesday
21.1.| 5291 | Wednesday
22.1.| 6142 | Thursday
I need to find the MAX and MIN values by the weekday. Note that my table is ordered by dates. I've heard not-so-great stories about VLOOKUP.
So the answers would be:
MAX
12.1.| 7083 | Monday
6.1. | 5021 | Tuesday
7.1. | 6785 | Wednesday
22.1.| 6142 | Thursday
16.1.| 6485 | Friday
MIN
5.1. | 3046 | Monday
13.1.| 3531 | Tuesday
21.1.| 5291 | Wednesday
15.1.| 2068 | Thursday
2.1. | 2981 | Friday
What would be the right formula?
You can use either array or standard pseudo-MINIF/MAXIF formulas to retrieve the value but then you will need a two column lookup to retrieve the value from the Date column.
      
The formulas for E4:F4,E11:F11 are:
'E4
=INDEX($A$2:$A$9999, MIN(INDEX(ROW($1:$9998)+(($B$2:$B$9999<>F4)+($C$2:$C$9999<>G4))*1E+99, , )))
'F4
=MAX(INDEX($B$2:$B$9999*($C$2:$C$9999=G4),,))
'AGGREGATE alternative for F4
=AGGREGATE(14, 6, 1/($C$2:$C$9999=G4)*($B$2:$B$9999),1)
'E11
=INDEX($A$2:$A$9999, MIN(INDEX(ROW($1:$9998)+(($B$2:$B$9999<>F11)+($C$2:$C$9999<>G11))*1E+99, , )))
'F11
=MIN(INDEX($B$2:$B$9999+($C$2:$C$9999<>G11)*1E+99,,))
`F11 where zeroes are discarded
=MIN(INDEX($B$2:$B$9999+(($C$2:$C$9999<>G11)+($B$2:$B$9999=0))*1E+99,,))
'AGGREGATE alternative for F11
=AGGREGATE(15, 6, 1/($C$2:$C$9999=G11)*($B$2:$B$9999),1)
Fill each E:F area down as necessary. These formula depend upon the weekday values in columns C & G being text strings; a different approach is required if these are actual dates formatted as mmmm

Resources