how to reference data from same point of time over last 30 days in Excel? - 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.

Related

Count values of an Excel column in different ranges

I want to count number of values in different ranges in an Excel column.
Example 1:
Imagine I have some data in 40 rows, each one happened in different time of day. Like the below image:
now I want to count number of row repeated in different ranges, for example, count number of rows that have time between 12:00 to 18:00, again count 18:00 to 00:00, and more to 11:59 (next 12:00)
Time range
Count
00:00 to 6:00
?
06:00 to 12:00
?
12:00 to 18:00
?
18:00 to 23:59
?
Finally I have a table with 4 rows that shows how many row I have in those ranges and I can create a chart by that.
Example 2:
Count people based on age range. result would be like this:
Age range
Count
12 to 18
3
18 to 25
5
25 to 35
4
35 to 45
1
45 to 60
2
P.S:
I used countif with logical AND, but it didn't work. like this: =COUNTIFS(C:C,"AND(<00:00, >2:00)")
A more correct use of COUNTIFS (which is different from COUNTIF), would be :
'Counts values strictly between 00:00 and 2:00
=COUNTIFS(C:C,">00:00",C:C,"<2:00")
Hope it helps

Allocating staff to 30 minute intervals

I’m trying to create either a spreadsheet or macro that allows me to put and employee start and finish time in and then show me by each half hour how many half hours they are in.
For example;
Employee 1 - 08:30 to 10:15
The output I would want is;
08:00 0
08:30 1
09:00 1
09:30 1
10:00 0.5
10:30 0
11:00 0
So between 8:30 and 9:00 shows as one because that employee was in during that half hour. But between 10:00 and 10:30 it shows 0.5 because the employee was only in for half of that period
Then as I add more data it tells me which half hours they are covering.
I’ve tried using the ceiling and floor values, counta, countif, countifs, v and hlookups but just can’t get the desired effect.
I’m guessing it would need to be a macro.
Assuming C1 and D1 contain the start and end times of a shift and column A contains the times, use the following formula in column B:
=IF(A2>D$1,C2,IF(AND(A2>=C$1,A3<=D$1),1,MAX(0,A3-D$1)/(1/48)))
Limitations: shifts cannot cross over days, days cannot start before 00:00 or end after 23:59

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.

Calculating a work week based on weekly time-sheet

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.

Resources