Generate a sequence of datetimes between 2 times - excel-formula

I am generating the timestamps in a day to send some messages to customers
Make a copy of sheet here: https://docs.google.com/spreadsheets/d/1a1-tVXxlZI4RlNxH4sIEejZhh0FKUFZ-jV88M8s-agE/copy
They are to be sent from Start time to End time and they cannot be sent after End time (My customers sleep after End time)
I have created a formula that can generate the sequence but it will not consider end time and keeps going continuously.
=arrayformula(text(SEQUENCE(200,1,value((datevalue(date(D2,C2,B2)) + timevalue(time(E2,F2,G2)))*1000),timevalue(time(I2,J2,0))*1000)/1000,"DD/MM/YYYY HH:MM:SS")&"*")
I would love the sequence to be generated the next day as well. This means if today is March 10 and start time is 10 with end time is 21 hrs
I need a sequence beyond the next day will resume from 11 March after 10 am
Those red dates must be skipped and continued from the next day

Basically, you wanted a sequence like this to generate times:
1
2
3
4
1
2
3
4
1
2
3
4
And sequence like this to generate days:
1
1
1
1
2
2
2
2
3
3
3
3
4
4
4
4
right?
If I'm correct, you should better change your sets to these:
You'll need these values:
10/03/2022 Start Date [F9]
10:01:00 Start Time [F11]
02:30:00 Step Time [F12]
5 Number of times in a day [F14]
60 Total number of Points is sequence [F15]
And there are 2 formulas, to make it simple.
The formula for time & time sequence is:
=ArrayFormula(F11 +F12*MOD(SEQUENCE(F15)-1,F14)+1)
And the formula for dates & dates sequence is:
=ArrayFormula(F9 -1 + CEILING(SEQUENCE(F15)/F14))
👉🏼
https://docs.google.com/spreadsheets/d/1TzkwCAsAjM_yK7jCwEj_iZD2wTxHWmbtkyZROk4lCJU/copy

Related

Excel: how to average with condition

We have an Excel sheet in which we collect some monthly data.
Each line contains a date and some value (in my boiled-down example here the date is always the first of each month and the values are [1..n]).
I am now trying to calculate an average of the values but not from ALL values but only those from the last quarter (i.e. where Date is >TODAY()-90).
TODAY() at the time of this writing is Jan. 30th, 2023, so I would expect the result to be 12, i.e. the average of the values for the last 3 months (11, 12, and 13).
A B
1 Date Value
2 01.01.2022 1
3 01.02.2022 2
4 01.03.2022 3
5 01.04.2022 4
6 01.05.2022 5
7 01.06.2022 6
8 01.07.2022 7
9 01.08.2022 8
10 01.09.2022 9
11 01.10.2022 10
12 01.11.2022 11
13 01.12.2022 12
14 01.01.2023 13
15
16 Avg. last 3 months:
17 #VALUE! <-- =AVERAGE(IF(A2:A14>(TODAY()-90);B2:B14;0))
18 #DIV/0! <-- =AVERAGEIF(A2:A14;">(TODAY()-90)";B2:B14)
I tried several approaches using AVERAGE(...) and AVERAGEIF(...) functions as shown above (and also several other variants) but I could not manage to get this working. All I ever get are error messages like #VALUE! or #DIV/0! :-(
Any idea how I can convince AVERAGE(IF) to only consider those values where the date is >today-90 days?
As per my comment:
=AVERAGEIF(A2:A14,">="&TODAY()-90,B2:B14)
Where the ampersand calculations operator is just a less-verbose way to concatenate different values. Here the 2nd parameter takes a string so using both parts on the left and right of the operator we create a value such as ">=12345".

How do I count the number of cells in a column against criteria in another column

I need help creating a formula to count number of unique delivery stops each day. The table below is similar to my actual data.
Name
Address
Sun
Mon
Tues
Wed
Bob
1 Main St
1
0
1
2
George
3 Main St
3
0
1
2
Tom
4 Main St
4
0
1
2
Harry
1 Main St
0
0
1
2
Randy
1 Main St
0
0
4
2
Homer
5 Main St
2
0
1
2
Bill
10 Main St
3
0
1
2
Jim
1 Main St
1
0
1
2
Joe
2 Main St
1
0
1
2
For instance, "1 Main St" is marked 4 times on the chart, but on Sunday there were 2 deliveries but only 1 actual stop at that location.
How would I go about calculating that based with a formula? I originally tried a ```=SUMPRODUCT```` but it wasn't calculating correctly, it would count each delivery stop, I'm not sure how to make it not count 0's and to combine multiple deliveries to the same address as a single delivery.
My last formula was "=SUMPRODUCT((COUNTIF($D$6:$D$96,$D$6:$D$96)=1)*$J$8:$J$98)
Where Column D is the addresses and J starts the delivery counts on Sunday.
Thanks
EDIT
Sorry, I wasn't clear with my question: I need a way to count the number of stops made per day (so if an address has multiple deliveries to different people, it's just counted as a single stop and 0's are skipped). Using Excel 2013
After many, many attempts, here it is...
Answer:
=SUM(IF(LEN(UNIQUE(FILTER(B2:B10;C2:C10>0;0);FALSE;FALSE))>1;1;0))
Where B2 is the first address, C2 is the first row under sunday.
This will give you unique delivery locations. So, if you visit the same place multiple times in one day, it is still counted as 1. If 0, it is counted as 0.
Your question was VERY unclear. Next time around, please tell us what you want the result to be.
This answer will give 6 for Sunday. If there are no deliveries, it will be zero. This last point took me hours to solve. COUNTIF won't work on single cells, only arrays. COUNT only works on numbers, COUNTA... Well, apparently COUNTA counts empty arrays (like if FILTER returns nothing). So I had to get the length (>1 for some reason). If it was greater than 1 in length, add 1, otherwise 0. And finally SUM it all.
Like I said, this is to calculate deliveries on Sunday, so this formula will be repeated for the other days.
Hope you like it! ^_^

Excel Time Comparison and Subtraction

I am trying to do a time subtraction in excel of 30 minutes and I am running into a speed bump. So the table I have are as follows.
Table "Schedule"
Column 1 is day of the week (Mon-Sun) (formated as general, as this is plain text)
Column 2 is start time of the shift (formated as h:mm AM/PM)
Column 3 is end time of the shift (formated as h:mm AM/PM)
Column 4 is duration of the shift (start to end) (formated by formula (TEXT(col3-col2,"h:mm")) )
Column 5 is paid hours (if the total hours is over 6.5 then subtract 0.5 hours for an unpaid lunch) (formula IF(col5>"6:30",col5-"0:30",D5) )
The issue is any time allotment over 10 hours start to end (where column 4, the duration hits 10 hours) no lunch is subtracted at all.
So...
Start 9:00 AM, End 6:59 PM, Hours Total 9:59, Hours Paid 9:29
But...
Start 9:00 AM, End 7:00 PM, Hours Total 10:00, Hours Paid 10:00
and that should obviously not happen. I can't find anything on google so I figured the excel gurus here may have some advice.
Thanks!
If your time columns are stores using excel's dedicated time format, this should be straightforward. Mixed data types are likely your problem.
First, be sure your time columns (columns 2 and 3) are set using the time function, i.e.,
=time(hours,minutes,seconds)
Then, you should be able to add and subtract easily.
Column 4: = column 3 - column 2
... then subtract 30 minutes also using the time() function:
Column 5: = if(column 4 > time(6,30,0),column 4 -time(0,30,0),column 4)
Excel stores time values from 0 to 1. So 24 hours=1, 12 hours=.5 etc. That means 6.5 hours=0.270833333 and .5 hours=0.020833333. As a result you can just do a simple if statement.
=IF(D2>0.270833333,D2-0.020833333,D2)
To turn it into a time format, is to just use excel's time formating options.

Count num of values within range on every Nth cell

We have a data-set generated by an HR system of staff times, which isn't in the most helpful of formats.
We need to count the # of staff who start work before 10.00, and split those counts by week number (1-4) and day (Sun-Sat).
Every group of rows (1-4) is an individual.
Here's an example day's data:
Week Start
1 -
2 10:00
3 09.00
4 09.55
1 09:25
2 10.00
3 10:25
4 10.25
1 09:25
2 09.55
3 08:00
4 10.00
1 10:25
2 09.25
3 09:25
4 10.15
1 10.00
2 08:25
3 09.45
4 11:25
So I can count the occurence of start times before 10am on the entire column with:
=COUNTIFS(L5:L203,">=00:30",L5:L203,"<=10:00")
but to do separate counts for every 4th row (so sum all for ones on week 1, all on week 2, etc) is beyond me.
I tried the following after searching similar questions, but it didn't work:
=COUNTIFS((MOD(ROW(L5:L203),5)=0),">=00:30",(MOD(ROW(L5:L203),5)=0),"<=10:00")
Ideally I'd be able to put values into a table with a count for week 1 on Sunday, week 2 on Sunday, week 1 on Monday, and so on.
Any ideas?
To count the weeks use:
=COUNTIFs(B$2:B$21,"<=10:00",$A$2:$A$21,"=1")
=COUNTIFs(B$2:B$21,"<=10:00",$A$2:$A$21,"=2")
Changing =1, =2, =3, =4 for each weeks count. If column B is Monday and column C is Tuesday, you can drag the above formulas right across the row to get the weekly counts for other days.

FCR calculations in excel

I am trying to work the (First Contact Resolution) FCR in excel however so success.
Does anyone know an automated formula used in excel?
We have been trying to use formulas to check how many times a customer with the same customer ID calls us in 7 days.
Assuming your requirement
ID Date Calls Count in last 7 days from today
1 13-Mar-17 2
2 14-Mar-17 0
5 15-Mar-17 1
1 16-Mar-17 2
3 17-Mar-17 1
5 18-Mar-17 1
7 19-Mar-17 1
9 20-Mar-17 1
1 21-Mar-17 2
13 22-Mar-17 1
2 23-Mar-17 0
17 24-Mar-17 0
5 25-Mar-17 1
21 26-Mar-17 0
Putting ID in Column A and Dates in Column B and records starts from row 2
put this formula in Cell "C2":
=COUNTIFS(A:A,A2,B:B,">="&TODAY()-6,B:B,"<="&TODAY())
and drag it all way down to see the number of calls
or put this formula if you want to calculate last 7 days from the date in sheet:
=COUNTIFS(A:A,A2,B:B,">="&B2-6,B:B,"<="&B2)
Please let me know if you meant something else as I tried my best to assume the senario.

Resources