Google sheets IF THEN (Give popup) - google-sheets

im working on a google sheets project to handle restaurant bookings.
I want to add an error or alert if table bookings for a time range exceed a stated amount.
I have 5 slots per 30mins setup on the sheet, ie, :
TIME Covers
12:00 - 2
12:00 - 5
12:00 -
12:00 - 4
12:00 - 3
------------------
12:30 - 1
12:30 - 7
12:30 -
12:30 -
12:30 - 3
Each time slot has a "covers" column which contain the amount of people for the booking. IF the total for each 30mins amounts to more than 20, i want to show an alert.
Any ideas or suggestions on achieving this?

I suggest you complete your spreadsheet with a total per slot column and conditional formatting
in C1
={"total per slot";arrayformula(if(A2:A="",,sumif(A2:A,A2:A,B2:B)))}

Related

Time function in sheets

I have the data of 4000 employees in google sheets along with their shift timings (9 hour long shift) spread across 24 hours. I wish to use a formula to understand the most common timing these employees are available in the office (09:00 to 18:00). My results would be 09:00 to 11:00, 11:00 to 13:00, 13:00 to 15:00, 15:00 to 18:00, 18:00 to 22:00, 22:00 to 09:00.
I could have used this formula to derive to the value:
=IF(AND(TIMEVALUE(A2)>=TIMEVALUE("09:00"), TIMEVALUE(A2)<=TIMEVALUE("11:00")), "09:00 to 11:00",
IF(AND(TIMEVALUE(A2)>=TIMEVALUE("11:00"), TIMEVALUE(A2)<=TIMEVALUE("13:00")), "11:00 to 13:00",
IF(AND(TIMEVALUE(A2)>=TIMEVALUE("13:00"), TIMEVALUE(A2)<=TIMEVALUE("15:00")), "13:00 to 15:00",
IF(AND(TIMEVALUE(A2)>=TIMEVALUE("15:00"), TIMEVALUE(A2)<=TIMEVALUE("18:00")), "15:00 to 18:00",
IF(AND(TIMEVALUE(A2)>=TIMEVALUE("18:00"), TIMEVALUE(A2)<=TIMEVALUE("22:00")), "18:00 to 22:00", "22:00 to 09:00")))))
but the problem is the timings are not in the time format but they are in text format
Here's my take:
Suppose Column A has clock ins, and Column B has clock outs. Let Column D have Times starting at 00:00 and going up to 33:00 (8am next day) in 5 minute (or 30, 60 etc) increments.
Let column E be the amount of clock in and outs that an employee was in the office at the time referred to in E.
We will define E to be =COUNTIFS($A$2:$A$9999,"<="&D2,$B$2:$B$9999,">="&D2).
Next, apply some conditional formatting to highlight the most busy times.
Note that you will need only the times of day, which it sounds like you have, but you will need to convert overnight shifts to not wrap around midnight.

How can I calculate time spent on status between 0900 and 1700?

I have start dates with times and end dates with times tracking when work was entered into a status and when it was completed. I'd like to know how many working hours were spent doing the task.
For example:
Start Date
End Date
Working Hours (Time Spent between 9 AM - 5 PM)
8/1/2022 10:03 AM
8/5/2022 4:43 PM
?
8/8/2022 9:03 AM
8/10/2022 3:34 PM
?
8/10/2022 11:13 AM
8/15/2022 4:57 PM
?
I'd like to know how many hours were spent working between 9 AM and 5 PM, excluding weekends and public holidays.
How can I do this calculation in Google Sheets?
Try:
=(NETWORKDAYS(A2,B2)-1)*("5:00 PM"-"9:00 AM") +IF(NETWORKDAYS(B2,B2),MEDIAN(MOD(B2,1),"5:00 PM","9:00 AM"),"5:00 PM") -MEDIAN(NETWORKDAYS(A2,A2)*MOD(A2,1),"5:00 PM","9:00 AM")
Drag down to column.
Result:
Using NETWORKDAYS() function to only count the working days excluding weekends, then multiply it by the number of hours between 9AM and 5PM.
This will return a number which is in a form of the total number of days. You then format the cell to Duration.
To format the cell:
Highlight the cells -> Then on the menu click Format -> Number -> Duration
Final Result:
References:
NETWORKDAYS()
Get Work hours between dates

count how many specific days are in a time period

I want to count say how many Mondays we have from 2022-02-01 - 2022-03-01. I found smth like this:
=SUMPRODUCT(WEEKDAY(B4:C4)=2) - B4 and C4 are the dates
But it returns 0. I assume it only checks if specific date is the specific day. Any ideas how I can do this but for a date range? So how count how many Mondays there are in February
I also found this
=NETWORKDAYS.INTL(B4;C4;"1000000")
but this returns 25
You can take advantage of the NETWORKDAYS.INTL function by using the string method to make all the days as weekend except for Monday.
The String method states:
weekends can be specified using seven 0’s and 1’s, where the first number in the set represents Monday and the last number is for Sunday. A zero means that the day is a work day, a 1 means that the day is a weekend. For example, “0000011” would mean Saturday and Sunday are weekends.
In this case since you only want to know the Mondays, the string would be "0111111" and the function would look like:
=NETWORKDAYS.INTL(StartDate,EndDate,"0111111")
I think this is right. It's counting inclusively so you would get five Mondays starting on Monday 7th Feb 2022 and ended on Monday 7th March 2022 for example.
=floor((B2-(A2+7-weekday(A2,12)))/7)+1
where A2 and B2 contain the start date end end date.
Obvs nul points for me again but for the record this could be generalised if you put the day number in C2 (e.g. 1 if you want to find Sundays, 2 for Mondays):
=floor((B2-(A2+7-weekday(A2,10+C2)))/7)+1

Google sheets formula to calculate hours after a specific time and day

I am new to google sheets, but I have this very simple and basic tracking system for my work schedule. I wish to make a formula so it automatically finds the number of hours on nights and weekends column, after a specific time.
So ex. night hours between 9 pm-11 pm Monday - Friday and weekend hours between 2 pm-8 pm on Saturday and Sunday.
Check if you get the expected hours (sorry for the layout a bit different!)
https://docs.google.com/spreadsheets/d/1YuY_8XgMUsPtBPJlBgxDFgz8JKB3lCmn2e6vVEutvBY/edit?usp=sharing
test if we =WEEKDAY(A4,2)>5
day on monday-friday =if(D4,, max(0,min(21/24,C4)-B4))
night on monday-friday =if(D4, ,max(0,C4-max(21/24,B4)))

Googl Sheets - Time Range to Table

I want to take a time range and convert it to minutes within a table of 30 minute segments. For example, Bob works from 3:35 AM to 5:00 AM. So within the table from 3:30 AM - 4:00 AM should represent 25 minutes, because Bob was working a total of 25 minutes during that time slot. Then the time slots for 4:00 - 4:30 AM and 4:30 - 5:00 AM would both have 30 in their corresponding cells.
Apologies to leave this so broad but I honestly have no idea where to start and this forum has been immensely helpful.
https://docs.google.com/spreadsheets/d/1YpHU-UHlqXL6c8I27zSDZaRu72ViUw5W6RPru-HE3Iw/edit#gid=0
Any help is appreciated.
For each 30-minute interval, you have to check whether these two conditions are met:
The interval start time (3:30) falls between the employee start and end time (3:35 and 5:00).
The interval end time (4:00) falls between the employee start and end time.
If any of these conditions are met, the working time for that interval won't be 0. The working time will be the difference between the minimum of both end times (4:00 and 5:00) and the maximum of both start times (3:30 and 3:35).
Translated to sheets functions, you could do something like this:
=IF(MIN($D2,O$1)-MAX($C2,N$1)>0,TIMEVALUE(MIN($D2,O$1)-MAX($C2,N$1))*24*60,0)
Or, alternatively, this:
=IF(OR(AND($C2<N$1,N$1<$D2),AND($C2<O$1,O$1<$D2)),TIMEVALUE(MIN($D2,O$1)-MAX($C2,N$1))*24*60,0)

Resources