Filling in time gaps in Excel - excel

I have the following in excel sheet:
start end value
1 26/11/2014 13:00 26/11/2014 20:00 decreasing
2 26/11/2014 20:00 27/11/2014 09:00 increasing
I would like to transfer the above table to a table in which each row time is opened and filled in with the value. The time gap is filled in from the start time to the end time - 1, as followed:
date hour value
1 26/11/2014 13:00 decreasing
2 26/11/2014 14:00 decreasing
3 26/11/2014 15:00 decreasing
4 26/11/2014 16:00 decreasing
5 26/11/2014 17:00 decreasing
6 26/11/2014 18:00 decreasing
7 26/11/2014 19:00 decreasing
8 26/11/2014 20:00 increasing
9 26/11/2014 21:00 increasing
10 26/11/2014 22:00 increasing
11 26/11/2014 23:00 increasing
12 26/11/2014 00:00 increasing
13 26/11/2014 01:00 increasing
14 26/11/2014 02:00 increasing
15 26/11/2014 03:00 increasing
16 26/11/2014 04:00 increasing
17 26/11/2014 05:00 increasing
18 26/11/2014 06:00 increasing
19 26/11/2014 07:00 increasing
20 26/11/2014 08:00 increasing

Assuming this is the location of your original data :
B2 ---> 26/11/2014 13:00
B3 ---> 26/11/2014 20:00
C2 ---> 26/11/2014 20:00
C3 ---> 27/11/2014 09:00
D2 ---> decreasing
D3 ---> increasing
And in sheet2, put some labels :
B1 ---> date
C1 ---> hour
D1 ---> value
Some date generator.. Assuming Sheet1!B2 is the start date..
B2 ---> =DATE(YEAR(Sheet1!B2),MONTH(Sheet1!B2),DAY(Sheet1!B2))
C2 ---> =TIME(HOUR(Sheet1!B2),MINUTE(Sheet1!B2),SECOND(Sheet1!B2))
B3 ---> =IF(INT((C2+TIME(1,0,0)))>INT(C2),B2+1,B2)
C3 ---> =IF((TIME(HOUR(C2),MINUTE(C2),SECOND(C2))+TIME(1,0,0))>1,TIME(HOUR(C2),MINUTE(C2),SECOND(C2))+TIME(1,0,0)-1,TIME(HOUR(C2),MINUTE(C2),SECOND(C2))+TIME(1,0,0))
and lastly, using and Sheet1!C3 as the end date, define output.
D2 ---> =IF((B2+IF(C2=1,0,C2))<Sheet1!$C$3,IF((B2+IF(C2=1,0,C2))<Sheet1!$C$2,Sheet1!$D$2,Sheet1!$D$3),"")
drag the until E21. Done.
I hope that'll help. Do buzz me if there is any part of the formula that you can't understand. ( :

Related

How to show IDs which are in ready status within certain time range

I'm pretty new Qlik Sense user, and I'm making pivot table which shows those patients who have been in ready status between selected time range. I have columns OWNER_ID, START_TIME, END_TIME & STATUS. START_TIME & END_TIME are in hours, for example, 6 which means 6 o'clock.
OWNER_ID
column contains those patients who have "ready status".
For now my time selection is made with filter pane and you can select "0-2 o'clock", 3-5 o'clock", "6-8 o'clock" et cetera. When I select a time range, for example 6-8 o'clock, pivot table shows those patients whose start time is 6, 7 or 8, but it should show those who have been in ready status between 6 and 8 o'clock.
I have tried aggr() chart function like
=aggr(max({1<END_TIME={">=$(=min(EHour))"}>} END_TIME),END-TIME)
within Data -> Dimensions -> END_TIME -> Field, but that doesn't work - pivot table shows OWNER_IDs whose END_TIME is greater than given time range.
How to solve this?
Seems to me if you had a data table that looked like this:
OWNER_ID
START_TIME
END_TIME
STATUS
001
05:00
10:00
Ready
002
09:00
13:00
Not Ready
003
21:00
00:00
Not Ready
004
10:00
11:00
Ready
005
09:00
12:00
Ready
...and then a table with the hours information:
START_TIME
ETIME
EHOUR
00:00
01:00
0-2 o'clock
01:00
02:00
0-2 o'clock
02:00
03:00
0-2 o'clock
03:00
04:00
3-5 o'clock
04:00
05:00
3-5 o'clock
05:00
06:00
3-5 o'clock
06:00
07:00
6-8 o'clock
07:00
08:00
6-8 o'clock
08:00
09:00
6-8 o'clock
09:00
10:00
9-11 o'clock
10:00
11:00
9-11 o'clock
11:00
12:00
9-11 o'clock
12:00
13:00
12-14 o'clock
13:00
14:00
12-14 o'clock
14:00
15:00
12-14 o'clock
15:00
16:00
15-17 o'clock
16:00
17:00
15-17 o'clock
17:00
18:00
15-17 o'clock
18:00
19:00
18-20 o'clock
19:00
20:00
18-20 o'clock
20:00
21:00
18-20 o'clock
21:00
22:00
21-23 o'clock
22:00
23:00
21-23 o'clock
23:00
00:00
21-23 o'clock
...then you'd have an association between [START_TIME] and [EHOUR], such when you select [EHOUR], it correctly filters your data by the [START_TIME]. Then, you only have to adjust your Set Expression, which I think should look more like this:
Only({<STATUS={'Ready'}>} STATUS)
Here's a screenshot GIF of how it looks for me:
Hopefully I understood that correctly!

How to sum values in Excel that occur between 2 hours

I would like to sum the sales depending on the time diapasons of the day-night in which they occur. For example, I would like to sum all sales that happened between 22:00h and 2:00h.
Hour Sales
18:58 49
18:00 49.5
03:01 31
20:00 139
09:15 61.5
11:36 5
08:00 24
16:32 25
12:30 96.5
17:30 75.5
09:00 80
00:10 24
15:00 24
18:00 216
09:30 24
06:30 47.5
So if I try to do a sumifs where the hour is >=22:00 and <23:00, the formula works. However, if I try to sumifs the values between 22:00 and 2:00, in other words the first criteria is ">=22:00" and the second is "<2:00", the sumifs cannot work. I do understand why but I'm struggling to find an alternative way to solve this task.
As stated, we need to add 1 when it rolls to the next day, which means SUMPRODUCT:
=SUMPRODUCT($B$2:$B$17,((E2<D2)+$A$2:$A$17>=D2)*(($A$2:$A$17<D2)+$A$2:$A$17<(E2<D2)+E2))

formula to calculate work hours and sort by employee in an overlapping data array

I have a .XLXS table with worker names, start times, and end times. I want to show the total hours worked by worker while ignoring overlapping periods.
For example if "Bob" works from 0800 to 1400 and also works from 0900 to 1300 his total time for that day should be 6 hours. If "Joe" works 0700 to 0900 his time for that day is 2 hours.
The number of workers varies and six months of data is about 2100 rows.
The formula provided by "barry houdini" to "Formula that will calculate total hours in overlapping date array" works for one worker but I don't know enough about Excel to make it sort for multiple workers.
=SUMPRODUCT((COUNTIFS(B:B,"<"&MIN(B:B)+ROW(INDIRECT("1:"&ROUND((MAX(C:C)-MIN(B:B))*1440,0)))/1440-1/2880,C:C,">"&MIN(B:B)+ROW(INDIRECT("1:"&ROUND((MAX(C:C)-MIN(B:B))*1440,0)))/1440-1/2880)>0)+0)/60
MOD_BY START_DATETIME END_DATETIME total time
bob 1/2/19 17:30 1/2/19 18:45 3.2500
bob 1/2/19 21:00 1/2/19 21:15
bob 1/2/19 21:00 1/2/19 22:00
bob 1/2/19 15:00 1/2/2019 16:00
joe 1/2/19 17:30 1/2/19 18:45
joe 1/2/19 21:00 1/2/19 21:15
joe 1/2/19 21:00 1/2/19 22:00
joe 1/2/19 15:00 1/2/2019 16:00
My objective is to have an output of total hours worked by worker. The formula as provided gives a total for the entire file without breaking it down by worker.
You will need MAXIFS and MINIFS which means you need Office 365 Excel:
=SUMPRODUCT(--(COUNTIFS(A:A,"bob",B:B,"<=" & MINIFS(B:B,A:A,"bob") + ROW($XFD$1:INDEX($XFD:$XFD,ROUND((MAXIFS(C:C,A:A,"bob")-MINIFS(B:B,A:A,"bob"))*1440,0)))/1440-1/2880,C:C,">=" & MINIFS(B:B,A:A,"bob") + ROW($XFD$1:INDEX($XFD:$XFD,ROUND((MAXIFS(C:C,A:A,"bob")-MINIFS(B:B,A:A,"bob"))*1440,0)))/1440-1/2880)>0))/60

Adjust given date range and interpolate values

Good afternoon,
I have a data set, which contains reporting dates and various parameters corresponding with this date. Each parameter provides a value related to the duration between the reports. So, the set contains multiple rows with the same date (but different time), and could contain a single row for which values are applicable to multiple dates.
Example of the set listed below:
Date Distance Price
02-01-2018 04:00 370 26.71
03-01-2018 04:00 357 27.31
04-01-2018 04:00 376 23.47
04-01-2018 04:48 8 0.72
04-01-2018 05:36 0 0.19
05-01-2018 04:00 328 23.77
05-01-2018 17:30 202 15.23
07-01-2018 17:13 7 1.54
08-01-2018 05:00 0 7.44
09-01-2018 05:00 0 3.89
10-01-2018 04:00 333 21.38
10-01-2018 11:00 110 6.40
What i would like to get:
Date Distance covered Price
02-01-2018 04:00 370 26.71
03-01-2018 04:00 357 27.31
04-01-2018 04:00 376 23.47
05-01-2018 04:00 336 24.67
06-01-2018 04:00 204 15.56
07-01-2018 04:00 4 0.77
08-01-2018 04:00 2 7.24
09-01-2018 04:00 0 3.93
10-01-2018 04:00 333 21.55
11-01-2018 04:00 110 6.40
I want to be able to choose a start date/time, and create a macro which automatically creates 24hr intervals after this date till the end of data set and interpolates the parameters.
Any help would be much appreciated. Thanks in advance.
Best regards,

Calculate hours outside normal working time

From my sample xls(office2007) listed below. I am trying to calculate the hours worked from 17:00 onwards. could someone show me how would I write the formula to achieve this.
Many thanks...
Leaving Time Arrival Time DeliveryTime RTB Time per Job hoursforDaysWork
09:30:00 11:05:00 11:15:00 11:15:00 01:45:00 12:00:00
11:15:00 12:15:00 12:30:00 13:30:00 02:15:00
13:30:00 15:30:00 15:45:00 15:45:00 02:15:00
15:45:00 18:15:00 18:30:00 18:30:00 02:45:00
18:30:00 19:00:00 19:45:00 21:30:00 03:00:00
Time in Excel is based upon parts of 24 (whole day) as explained in this article.
So assuming that you care about hours after 17:00, but not after midnight, the following should help you out:
=IF(C2<17/24,0,C2-17/24)*24
C2 is the cell the calculation is for, with 17/24 giving you the time for 17:00 (5pm). The *24 at the end converts the response to be in hours instead of partial day.

Resources