Calculating a work week based on weekly time-sheet - excel

I am trying to calculate work week hours which I want to match it with the company's paycheck earned amount. So far I have this:
7/12/2011 7.90
7/13/2011 8.03
7/14/2011 7.83
7/15/2011 7.97
7/18/2011 8.20
7/19/2011 8.12
7/20/2011 8.15
7/21/2011 6.07
7/22/2011 8.12
7/25/2011 8.13
7/26/2011 8.1
7/27/2011 8.4
7/29/2011 8.27
8/1/2011 8.33
8/2/2011 8.18
8/3/2011 8.22
8/4/2011 6.72
8/5/2011 7.57
8/8/2011 8.07
8/9/2011 8.28
8/10/2011 5.8
8/11/2011 8.8
8/15/2011 8.2
8/16/2011 7.95
8/17/2011 8.17
8/18/2011 8.1
8/19/2011 7.8
8/22/2011 8.18
8/23/2011 9.7
8/24/2011 8.17
8/25/2011 8.18
and want to match the total to this:
Check Date Earnings Start Earnings End Earn Type Earn Amount
8/10/2011 7/26/2011 8/10/2011 Salary 899.6
8/25/2011 8/11/2011 8/25/2011 Salary 888.28
The company's pay period varies, that's why these days don't follow.
So far I was using =SUMIFS functions but they are not giving the result I need.
Let me know if there's clarifications anyone needs!

You should be able to use =SUMIFS() to get the hours during the pay period.
=SUMIFS(B:B,A:A,">="&F4,A:A,"<="&G4)
Here,
column A contains the dates,
column B contains the hours,
cell F4 is the Earnings start date,
cell G4 is the Earnings end date.

Related

how to reference data from same point of time over last 30 days in Excel?

I have a data set of 1 minute data in Excel of last 30 days.
I am trying to compare today's value at 05:45:00 with average of last 30 days value at same time (05:45:00).
Completely stuck.
Can anyone help: Dataset looks like this:
Time Value
05:30:00 11.00
05:31:00 6.00
05:32:00 20.00
05:33:00 50.00
05:34:00 69.00
05:35:00 31.00
05:36:00 90.00
05:37:00 56.00
05:38:00 26.00
05:39:00 24.00
05:40:00 22.00
05:41:00 71.00
05:42:00 80.00
05:43:00 85.00
05:44:00 41.00
**05:45:00 44.00**
05:46:00 28.00
05:47:00 43.00
I did try to convert days in to minutes by doing
=(last day - first day)*1440
after that I am completely stuck what needs to be done. Not very proficient with Excel.
Are you aware how datetime works in Excel?
It is based on the value "1" being equal to one day.
So, the hour-value "05:30" equals "=5.5/24" as you can see from this screenshot:
So, If you want to add 30 days to a timestamp, just add the value 30.

Filtering discrepancies in duplicate measurements

I have a dataset with the following problem.
Sometimes, a temperature sensor would return duplicate readings at the exact same minute, where sometimes 1 of 2 of the duplicates is "reasonable" and the other is slightly off.
For example:
TEMP TIME
1 24.5 4/1/18 2:00
2 24.7 4/1/18 2:00
3 24.6 4/1/18 2:05
4 28.3 4/1/18 2:05
5 24.3 4/1/18 2:10
6 24.5 4/1/18 2:10
7 26.5 4/1/18 2:15
8 24.4 4/1/18 2:15
9 24.7 4/1/18 2:20
10 22.0 4/1/18 2:20
Line 5, 7 & 10 are readings that are to be removed as they are too high or low (doesn't make sense that within 5 minutes it will rise and drop more than a degree in a relatively stable environment).
The goal at the end with this dataset is to "average" the similar values (such as in line 1 & 2) and just remove the lines that are too extreme (such as line 5 & 7) from the dataset entirely.
Currently my idea to formulate this is to look at a previously obtained row, and if one of the 2 duplicates is +/- 0.5 degree, to mark in a 3rd column with TRUE so I can filter out all the TRUE values in the end. I'm not sure how to communicate within the if statement that I'm looking for a + OR - 0.5 of a previous number however. Does anyone know?
Here is a google sheet example that does what you want:
https://docs.google.com/spreadsheets/d/1Va9RjSeulOfVTd-0b4EM4azbUkYUb22jXNc_EcafUO8/edit?usp=sharing
What I did:
Calculate a column of a 3-item running average of the data using "=AVERAGE(B3:B1)"
Filter the list using "=IF(ABS(B2-C2) < 1, B2, )"
Calculate the average of the filtered list
The use of Absolute Value is what provides "+ OR -" that you were looking for. It is saying if the distance between two numbers is too much, then don't include the term.
So, A Simple Solution came to my mind. Follow the Following steps given below:
Convert Data to Table
Add a 4th column at the last
Enter the formula "Current Value - Previous Value"
Filter the Column with high difference values
Delete those rows of filtered data and you'll be left with Normal Values
Here's the ref. Image
Or If you want to consider the Same time difference only then do the following:
Convert your data to Table
Add 4th column at the end of table
Writhe the Following Formula to 4th Column
IF(Current_Time = Previous_Time, Current_Temp-Previous_Temp,"")
Filter and Delete the Data with high Difference
See the following Image:

How to split the time between two dates over daily columns

I am in much need of help please.
I have the table below.
It has about 300 rows and columns on the right for each day of the year starting 2015, ending 2019. I only entered a few columns here as an example.
What I need:
A formula to split the time (it can be hours or decimal days, it doesn't matter) between the two days on the left on the columns to the right.
In the rest of the days, which are not included in the period, I need a zero in those columns.
I manually entered the results I need so it can help you understand.
E.g.
On the first row:
The employee has spent
15 hours at destination in the first day of travel,
24 hours in the second day of travel
11:50 hours in the last day of travel.
All the rest of the columns to the right, which are not here, starting 1/4/2015 23:59 should give the result zero.
Thank You!!
Entry Date Exit Date 1/1/2015 23:59 1/2/2015 23:59 1/3/2015 23:59
1/1/15 9:00 1/3/15 11:50 15.00 24.00 11.50
As far as I can tell, it boils down to this
1.0 days 2.0 days 3.0 days 4.0 days
period=p in h/d.d p-(1-(so far)) p-(2-(so far)) p-(3-(so far)) 0
EDIT 2: I've come up with a formula.
NOTE:
This formula assumes existence of a column that specifies 0 hours of work between the "end date/time" column ("B") and first work hour ("D"), so you have it like this:
A B C D E F G H
1 Entry Date Exit Date ZERO 1/1/2015 23:59 1/2/2015 23:59 1/3/2015 23:59 1/4/2015 23:59 1/5/2015 23:59
2 1/1/15 9:00 1/3/2015 11:50 0 0.6243055556 1 0.49375 0 0.00
3
The extra column is there to avoid circular dependencies, since
we must "iteratively" accumulate the hours
The main formula for row 2 from column D being:
=MIN(D1-$A2,MIN(MAX(($B2-$A2) - SUM($C2:C2), 0),1))
Note: semicolons may be needed instead of commas in Excel as delimiters.
Note: the last digit in the formula depends on the unit. Here it is in days decimal. If hours, put 24.
In plain English, for a cell
Calculate sum of hours/days decimal in the range C to wherever - 1
Subtract result from the difference between start and end (total hours)
If less than 0, put 0 (MAX(x, 0))
If more than 1, put 1 (MIN(x, 1))
Choose between the result, or the difference between current date and start time, if it is smaller

Average column by specific datetime associated values

I have one column with the time in format "dd/mm/yyyy hh:mm" and another with the temperature for that time point. I am looking to calculate the average temperature of the day and night of each month separately. I.e. average all temperatures between 06:00 and 18:00 in May and all temperature between 18:00 and 06:00 in May and then the same for March and so on.
Time Celsius(C)
06/05/2016 10:49 28
06/05/2016 11:49 29
06/05/2016 12:49 31
06/05/2016 13:49 27.5
06/05/2016 14:49 24
06/05/2016 15:49 25
06/05/2016 16:49 24.5
06/05/2016 17:49 23.5
06/05/2016 18:49 23
06/05/2016 19:49 22.5
06/05/2016 20:49 22.5
I am currently using the following formula:
=AVERAGEIFS(C2:C3643,B2:B3643,">=01/05/2016",B2:B3643,"<=31/05/2016",B2:B3643,">=01/05/2016 06:00",B2:B3643,"<=31/05/2016 18:00")
To try and calculate an average if the date is within May and during the day - however it doesn't appear to be working and when I change the hour periods it still spits out the same number (which is the average for the month).
You can use a long SUMPRODUCT Formula:
For the 600 to 1800 in May:
=SUMPRODUCT(($A$2:$A$12>=DATE(2016,5,1))*($A$2:$A$12<=DATE(2016,5,31))*(MOD($A$2:$A$12,1)>=TIME(6,0,0))*(MOD($A$2:$A$12,1)<=TIME(18,0,0))*B2:B12)/SUMPRODUCT(($A$2:$A$12>=DATE(2016,5,1))*($A$2:$A$12<=DATE(2016,5,31))*(MOD($A$2:$A$12,1)>=TIME(6,0,0))*(MOD($A$2:$A$12,1)<=TIME(18,0,0)))
You can always replace all the DATE() and TIME() parts with cell references instead of hard coding them.
To get the between 1800 and 600 we need to shift it to an OR with + between the Time Boolean instead of *:
=SUMPRODUCT(($A$2:$A$12>=DATE(2016,5,1))*($A$2:$A$12<=DATE(2016,5,31))*((MOD($A$2:$A$12,1)<=TIME(6,0,0))+(MOD($A$2:$A$12,1)>=TIME(18,0,0)))*B2:B12)/SUMPRODUCT(($A$2:$A$12>=DATE(2016,5,1))*($A$2:$A$12<=DATE(2016,5,31))*((MOD($A$2:$A$12,1)<=TIME(6,0,0))+(MOD($A$2:$A$12,1)>=TIME(18,0,0))))
This relies on you creating a table of months and time ranges like below:
Enter this formula in E2 and drag around as needed. It's an array formula, so must be entered with Ctrl-Shift-Enter:
=AVERAGE(IF(
((MONTH($A$2:$A$101)=MONTH(E$1&1))*
((MOD(HOUR($A$2:$A$101)-LEFT($D2,2),24))>=0)*
((MOD(HOUR($A$2:$A$101)-LEFT($D2,2),24))<12)),
$B$2:$B$101))
Notes:
The MONTH(E$1&1) part lets you get a month number from text like
"Jan"
I used MOD and subtraction of the left part of the time range to get
the target hour in a range from 0 to 23. This made it possible to filter on values between 1 and 11.
If Barry Houdini were still around he could do it in half the space, I'm sure.
While working with datetime and when the actual day is reckoned beyond midnight like in 18 hrs to 6 hrs the next day, I find it useful to offset the time back and do the calculations.
6:00 to 18:00 =AVERAGE(IF((MONTH($A$2:$A$12-0.25)=D2)*(MOD($A$2:$A$12-0.25,1)<0.5),$B$2:$B$12,""))
18:00 to 6:00 =AVERAGE(IF((MONTH($A$2:$A$12-0.25)=D2)*(MOD($A$2:$A$12-0.25,1)>=0.5),$B$2:$B$12,""))
These are array formulas entered with Ctrl-Shift-Enter.
Here I am offsetting time by 0.25 days which is 6 hours.

Why don't #N/A and MAX (or MIN) play well with each other and what can I do abut it

I have a list of 12 cars and need to calculate MPG. I have the miles driven and fuel consumed, so MPG = miles / gallons of fuel is easy enough to program.
Then in the fourth column I want a "label" for the best and worst MPG and all others should just be blank. Here is my formula:
=IF(C1=MAX($C$1:$C$12),"MAX",IF(C1=MIN($C$1:$C$12),"MIN"," "))
Simple enough. A snippet of my data follows.
Miles Gallons
Driven Fuel MPG
1,145 101.936 11.2 MIN
1,277 91.226 14.0
4,561 376.270 12.1
3,655 236.647 15.4
2,598 204.620 12.7
2,948 222.591 13.2
2,384 153.914 15.5
1,808 127.940 14.1
3,034 168.387 18.0
3,763 234.053 16.1
3,237 196.615 16.5
1,530 72.812 21.0 MAX
Next Month
2,515 191.196 13.2
1,908 111.129 17.2
1,589 112.410 14.1
2,223 147.278 15.1
2,221 145.936 15.2
#N/A 142.165 #N/A
1,928 177.609 10.9
1,150 92.072 12.5
#N/A 67.651 #N/A
79 2.849 27.7
407 22.241 18.3
10,537 94.960 111.0
Obviously car 12 has bad data, but that's not my concern right now. What is giving me trouble is the #N/A values for cars 6 and 9. My handy dandy little formula
=IF(C1=MAX($C$1:$C$12),"MAX",IF(C1=MIN($C$1:$C$12),"MIN"," "))
returns #N/A for each vehicle. I have tried to use
If(NOT(ISNA(C1)),IF(C1=MAX($C$1:$C$12),"MAX",IF(C1=MIN($C$1:$C$12),"MIN"," ")),"#N/A")
and
If(ISERROR(C1),"#N/A" ,IF(C1=MAX($C$1:$C$12),"MAX",IF(C1=MIN($C$1:$C$12),"MIN"," ")))
with the same results.
Can my original equation be reworked to compensate for #N/A?
For Excel 2010 or later:
=IFERROR(LOOKUP(2,1/(C1=AGGREGATE({14,15},6,$C$1:$C$12,1)),{"MAX","MIN"}),"")
You may try using array formula
=IF(MAX(IF(ISERROR($C$17:$C$28), 10^-15, $C$17:$C$28))=C17,"MAX","")
This should give you what you want for Office 2010+:
=IFERROR(IF(C17=MIN(IF(ISNUMBER($C$17:$C$28),$C$17:$C$28)),"MIN",IF($C17=MAX(IF(ISNUMBER($C$17:$C$28),$C$17:$C$28)),"MAX",NA())),"")
If you're using Office 2007 or below, you want
=IF(ISERROR(IF(C17=MIN(IF(ISNUMBER($C$17:$C$28),$C$17:$C$28)),"MIN",IF($C17=MAX(IF(ISNUMBER($C$17:$C$28),$C$17:$C$28)),"MAX",NA()))),"",IF(C17=MIN(IF(ISNUMBER($C$17:$C$28),$C$17:$C$28)),"MIN",IF($C17=MAX(IF(ISNUMBER($C$17:$C$28),$C$17:$C$28)),"MAX",NA())))
It's an array formula so you'll have to enter it with Ctrl + Shift + Enter

Resources