Automatic calculation based on date and tickbox state - google-sheets

I am trying to build a spreadsheet to track and automatically calculate money when I am called out for work.
Here are the conditions:
Monday, Tuesday, Wednesday, Thursday - Standby Rate: £21
Friday, Saturday, Sunday, Bank Holidays - Standby Rate: £26
Monday, Tuesday, Wednesday, Thursday - Callout Rate: (Hours Worked * Hourly Rate) * 1.25
Friday, Saturday, Sunday, Bank Holidays - Callout Rate: (Hours Worked * Hourly Rate) * 1.5
I have a spreadsheet containing the following information:
Column A - Date | Date
Column B - Called Out | Checkbox, tick if yes
Column C - Duration | If called out, how long for
Column D - Calculation | Shows the calculation used to determine payment
Column E - Payment | Shows the payment
The sheet looks like this:
+------------+-------------+----------+---------------------+---------+
| Date | Called Out? | Duration | Calculation | Payment |
+------------+-------------+----------+---------------------+---------+
| 01/02/2021 | | | 21 | £21 |
| 02/02/2021 | | | 21 | £21 |
| 03/02/2021 | | | 21 | £21 |
| 04/02/2021 | | | 21 | £21 |
| 05/02/2021 | | | 26 | £26 |
| 06/02/2021 | TRUE | 2 | 26+((2*50)*1.5) | £176 |
| 07/02/2021 | TRUE | 1 | 26+((1*50)*1.5) | £101 |
| 15/02/2021 | | | 21 | £21 |
| 16/02/2021 | TRUE | 1.5 | 21+((1.5*50)*1.25) | £177.25 |
| 17/02/2021 | | | 21 | £21 |
| 18/02/2021 | | | 21 | £21 |
| 19/02/2021 | | | 26 | £26 |
| 20/02/2021 | | | 26 | £26 |
| 21/02/2021 | | | 26 | £26 |
+------------+-------------+----------+---------------------+---------+
I have had some success with the following formula to get the standby rates (K1 contains my actual hourly rate):
=SUM(IF(WEEKDAY(A2,2)>4,26,21),IF(WEEKDAY(A2,2)>4,(($K$1*C2)*1.5),(($K$1*C2)*1.25)))
But I need to make it account for Bank Holidays and perform a check to see if column B is TRUE, then if it calculates the payment as dictated above.
Any ideas?

Your constants are.
Standby Rate: £21 OR £26
Hourly Rate: £50
Always: Standby OR Called Out
Bank Holidays
Change your table and use this
=ArrayFormula(IF((WEEKDAY(A2:A22,2)>4)+(B2:B22=TRUE),26,21)+
IF((WEEKDAY(A2:A22,2)>4)+(B2:B22=TRUE),C2:C22*50*1.5,C2:C22*50*1.25))

My working spreadsheet is here
https://docs.google.com/spreadsheets/d/1N7d2-W7pRTqpO9L4DvSkmm4j7vaHpJZ2fMYAq-yVVPg/copy
I made it in a few stages and tried to make it as simple as possible.
First we determine day of the week based on date:
=WEEKDAY(A4,2)
I put it in Column C for illustration only
Then I make a table with rates for each day of the week (assuming that sunday is 1st day of the week) - you see this in columns J and K
Then I set daily rate based on day of the week and 2nd column of table:
=vlookup(weekday(A4,2),$J$1:$K$8,2,false)
I don't use arrayformula here, just copy down formula, so when it's national holiday or something, you can manually change rate.
Finally I calculate payment for each day.
I add standby rate to call out hours (if there are none it's just flat standby rate).
I multiply hours by 1,5 for days with 26 standby rate and by 1,25 for days with 21 standby rate:
=D4+B4*50*(if(D4=26,1.5,1.25))

Related

Google Sheets: Formatting a list of timestamped values to a weekly view

I'd like to transform a growing list of timestamps and values to a calendar-style weekly display in Sheets, with only one unique value per day and time of day not important.
I have tried to do this using an INDEX-MATCH for both: the week number and the day of the week, but I'm having trouble debugging it, due to the blank value of cells for future timestamps resolving to "Sat" when using the text() function.
=IFERROR(INDEX(ValuesRange,MATCH(Week,WEEKNUM(TimestampsRange),0),MATCH(Day,text(TimestampsRange,"ddd"),0),),)
Would appreciate advice for any more expedient formula.
Summary:
I want to go from:
+----------------------------+----+
| | |
+----------------------------+----+
| August 23, 2022 17:40:11 | 4 |
| August 29, 2022 11:20:30 | 8 |
| September 4, 2022 15:55:17 | 10 |
+----------------------------+----+
To :
+-----+-----+------+-----+-----+-----+
| | Mon | Tues | Wed | ... | Sun |
+-----+-----+------+-----+-----+-----+
| 34 | | 4 | | | |
| 35 | 8 | | | | 10 |
| ... | | | | | |
+-----+-----+------+-----+-----+-----+```
Paste this formula and drag down.
=ArrayFormula(SUBSTITUTE(
SPLIT(REGEXREPLACE(REGEXEXTRACT(REPT("F,",
WEEKDAY(A2,3)+1), "(.+).\z"), ".\z",TEXT(B2,"#")),","),"F",""))

Google Sheets - sumif using condition on row and column

I have a spreadsheet that looks like the following
TABLE 1
ID/Month | May | June | July | August | September | October
ID101 | 30 | 50 | 50 | 80 | 20 | 60
ID201 | 20 | 30 | 10 | 40 | 30 | 50
ID101 | 10 | 50 | 60 | 80 | 70 | 20
ID301 | 20 | 80 | 70 | 40 | 40 | 70
ID101 | 30 | 70 | 80 | 50 | 90 | 50
ID301 | 80 | 20 | 30 | 20 | 60 | 20
TABLE 2
ID | Date | Value
ID101 | July | ?
ID201 | September | ?
ID301 | June | ?
? is the sum of the values in TABLE 1 if the IDs matches, and if the row of dates are less than or equal to the dates specified in TABLE 2.
So
for ID101 | July | ? I need to find the sum of values in row ID101 in TABLE 1 and May/June/July columns
for ID201 | September | ? I need to find the sum of values in row ID201 in TABLE 1 and May/June/July/August/September columns
How do I do a sumif like an index match table where I can look up conditions in column (IDs) and rows (less than or equal to dates)
You can use SUMPRODUCT function:
=SUMPRODUCT((J2=$A$2:$A$7)*(MONTH(K2&1)>=MONTH($B$1:$G$1&1))*$B$2:$G$7)
To convert your month names to correct number using MONTH(K2&1) formula you must specify a United States locale in the spreadsheet settings
You'll want to do three things:
Un-pivot your table ("wide" to "long") so that each value is in its own row, identified by an ID and a Month (this is a little tricky)
Give your month a numeric value (the MONTH() function comes in handy)
Use SUMIFS to check the ID column and the Month column.
Here's a working sample: Google Sheets link

How do I make a calculation field reference specific values from a pivot table in google sheets

So I'm making a punch in/out dashboard in google sheets. It uses a google form to populate a sheet with my employees punches like so:
Timestamp | Name | Punch Type | Time
6/2/2020 15:09:55 | Bob | 1. Start Shift | 7:30:00 AM
6/2/2020 15:10:45 | Bob | 2. Start Lunch | 11:00:00 AM
6/2/2020 15:11:08 | Bob | 3. End Lunch | 11:30:00 AM
6/2/2020 16:01:04 | Bob | 4. End Day | 4:00:00 PM
...
I then used this source data to make a pivot table that looks like this:
AVERAGE of Time | Punch Type
Name | 1. Start Shift | 2. Start Lunch | 3. End Lunch | 4. End Day
Bob | 7:30:00 AM | 11:00:00 AM | 11:30:00 AM | 4:00:00 PM
...
In this pivot table, I want to add a column at the end that is a calculated field of
("4. End Day" - "1. Start Shift") - ("3. End Lunch" - "2. Start Lunch").
I'm encountering two road blocks here. First is when I go to add a calculated field in the pivot table editor panel, it creates 4 new columns instead of just one:
| Punch Type | Values
| 1. Start Shift | 2. Start Lunch | 3. End Lunch | 4. End Day
Name | AVERAGE of Time.. | AVERAGE of Time.. | AVERAGE of Time.. | AVERAGE of Time..
Bob | 7:30:00 AM | 0 | 11:00:00 AM | 0 | 11:30:00 AM | 0 | 4:00:00 PM | 0
...
I the second issue is I can't figure out of to reference the columns with the timestamps to do this calculation.
Basically my end goal is a pivot table that looks like this:
AVERAGE of Time | Punch Type
Name | 1. Start Shift | 2. Start Lunch | 3. End Lunch | 4. End Day | Total Hours
Bob | 7:30:00 AM | 11:00:00 AM | 11:30:00 AM | 4:00:00 PM | 8.0
...
Displayed below is how I have my Pivot Table settings in the Pivot Table Editor Panel, before I attempt to add the calculated field

Sum values in a range based on the date from another column above the cells

Here are my data :
+-------+------------+------------+------------+------------+------------+------------+
| Date | 01/01/2017 | 02/01/2017 | 03/01/2017 | 01/02/2017 | 02/02/2017 | 03/02/2017 |
+-------+------------+------------+------------+------------+------------+------------+
| Value | 1 | 0,5 | 0 | 2 | 0,5 | 1 |
+-------+------------+------------+------------+------------+------------+------------+
I trying to write a formula that would calculate all values for each month. So with my example right here I would get 1,5 for January and 3,5 for February.
I tried something with =SUMIF(), =OFFSET() and =MONTH() so that it would only sum the values that share the same month based on the date above them, but I tried everything I always get a syntax error.
Does anybody have an idea ? Is it even possible without doing scripts ?
Thank you very much and have a good day.
OK so I found a way with =FILTER() :
=SUM(FILTER(2:2;MONTH(1:1)=MONTH(XXX)))
Where XXX here is the month I want to calculate. In my case I do it from another sheet :
+---+------------------------------------------------------------------+------------------------------------------------------------------+------------------------------------------------------------------+
| | A | B | C |
+---+------------------------------------------------------------------+------------------------------------------------------------------+------------------------------------------------------------------+
| 1 | Jan. 2017 | Feb. 2017 | Mar. 2017 |
| 2 | =SUM(FILTER('OtherSheet'!2:2;MONTH('OtherSheet'!1:1)=MONTH(A1))) | =SUM(FILTER('OtherSheet'!2:2;MONTH('OtherSheet'!1:1)=MONTH(B1))) | =SUM(FILTER('OtherSheet'!2:2;MONTH('OtherSheet'!1:1)=MONTH(C1))) |
+---+------------------------------------------------------------------+------------------------------------------------------------------+------------------------------------------------------------------+
Which gives me :
+-----------+-----------+-----------+
| Jan. 2017 | Feb. 2017 | Mar. 2017 |
+-----------+-----------+-----------+
| 1,5 | 3,5 | 2 |
+-----------+-----------+-----------+

iOS view component but can't find correct name for it

I'm looking for ready to use (can be paid) view component for iOS that looks like calendar day view but the day can show me events per persons or workplaces so I can see on one view when there is a free gap so I can make an appointment for this workplace. Imagine we are the dentist salon and we have 3 workplaces. We need a view that will help us to see is that workplace actually busy or free and we need this only per day. Currently in iOS Calendar We are able to see only events for one workplace but we need to add another column for second workplace and so on for a particular day. What to look for in google? What phrases can be useful to find such component?
| Monday 10.05.2015 |
------------------------------------------------
| Time | Workplace 1 | Workplace 2 |
| 7:00 | | Cleaning |
| 8:00 | Mr. Brux | |
| 9:00 | | Mr. Griffin |
| 10:00 | Cleaning | |
| 11:00 | | Mrs. Boxa |
| 12:00 | | |
| 13:00 | Mr. Bravo | Mr. Cabad |
| 14:00 | | |
| 15:00 | | |
| 16:00 | | |

Resources