Google Sheets availability chart formula - google-sheets

I am putting an overtime sheet together that staff can show their availability for the Saturday on a table with name and date with a simple Y/N, I also have another table for the hours each person has accumulated.
Based on several staff members saying Y to their availability (we have two members of staff in) I would like two cells to display the name of staff that has the least number of hours to their name.

Column A is the name
Column B is the hours they have worked
Column C is the checkbox,
checked meaning they will work overtime.
The following formula will return the two willing to work overtime with the least hours.
=query(A:C,"select * where A is not null and C = TRUE order by B limit 2")

Related

How to create a cumulative report based on differences between data updated daily in google sheets?

I am trying to create a report from another report(source sheet). :)
The source sheet updates daily automatically by inserting new rows with progress on sales on top of the rows completed a day before:
Date
Product
Units sold
11/15
A
35
11/15
B
12
11/15
C
18
11/14
A
30
11/14
C
11
11/14
B
10
11/13
F
88
11/12
B
7
11/12
A
29
11/12
C
10
11/11
C
8
11/11
A
29
11/11
B
3
The "Units sold" column is cumulative meaning that a newer record on a certain product will show a greater or equal value to a previous record on that specific product.
New products appear in the source sheet when entering the company and they disappear from it when they are sold out, pretty much randomly. (e.g. product "F" that showed up and sold out in the same day)
In the first column in the source report i already found a formula that concatenates date and product and is used by another reports.
To solve this, in the results report i made on column T the same concat of date and product. Then, in my new report, in the results column, i used the following formula: =vlookup(T2,Source!$A2:$C$10000,3,0)-vlookup(T2,Source!$A3:$C$10000,3,0) with the intention to obtain the difference between the amount of products sold in the last day vs the amount of products sold in the day before it, or, better said, the amount of each of the products sold on a specific date. Finally, by using a column of =year() and one of =month() applied on date column and a couple of pivot tables i was able to obtain the value of the daily increment for each and/or year.
The problem i couldn't find a solution for is that when the source sheet updates, the new rows added with the freshest data move down the cell references from the vlookup formula i used in the results sheet.
Please help me find a way to "pin down" the cell references in the vlookup formula without being affected by the new rows insertions.
Thank you!
to "pin down" the references you can use INDIRECT
example:
A1:A >>> INDIRECT("A1:A")

Google Sheet: formula to loop through a range

It's not hard to do this with custom function, but I'm wondering if there is a way to do it using a formula. Because datas won't automatically update when using custom function.
So I have a course list sheet, each with a price. And I'm using google form to let users choose what courses they will take. Users are allowed to take multiple courses, so how many they will take is unknown.
Now in the response sheet, I have datas like
Order ID
User ID
Courses
Total
1001
38
courseA, courseC
What formula to put here?
1002
44
courseB, courseC, courseD
What formula to put here?
1003
55
courseE
What formula to put here?
and the course sheet is like
course
Price
A
23
B
33
C
44
D
23
E
55
I want to output the total for each order and am looking at using FILTER to do this. Firstly I can get a range of unknown length for the chosen courses
=SPLIT(courses, ",") // having named the Courses column as "courses"
Now I need to filter this range against the course sheet? not quite sure how to do it or even if it is possible. Any hint is appreicated.
try:
=ARRAYFORMULA(IF(A2:A="",,MMULT(IFERROR(
VLOOKUP(SPLIT(C2:C, ", "), {F1&F2:F, G2:G}, 2, 0))*1,
ROW(INDIRECT("1:"&COLUMNS(SPLIT(C2:C, ", "))))^0)))
demo spreadsheet
As I need time to digest #player0's answer, I am doing this in a more intuitive way.
I create 2 sheets to store intermediate values.
The first one is named "chosen_courses"
Order ID
User ID
1001
=IFERROR(ARRAYFORMULA(TRIM(SPLIT(index(courses,Row(),1),","))),"")
1002
=IFERROR(ARRAYFORMULA(TRIM(SPLIT(index(courses,Row(),1),","))),"")
1003
=IFERROR(ARRAYFORMULA(TRIM(SPLIT(index(courses,Row(),1),","))),"")
In this sheet every row is a horizontal list of the chosen courses, and I created another sheet
total
course price
=IF(isblank(order_id),"",SUM(B2:2))
=IFERROR(VLOOKUP('chosen_courses'!B2,{course_Names,course_price},2,false),"")
=IF(isblank(order_id),"",SUM(C2:2))
=IFERROR(VLOOKUP('chosen_courses'!B2,{course_Names,course_price},2,false),"")
=IF(isblank(order_id),"",SUM(D2:2))
=IFERROR(VLOOKUP('chosen_courses'!B2,{course_Names,course_price},2,false),"")
course_Names,order_id and course_price are named ranges.
This works well, at least for now.
But there is a problem:
I have 20 courses, so in the 2nd sheed, there are 21 columns. And I copy the formulas to 1000 rows because that is the maximum rows you can get to using ctrl+shift+↓ and ctrl+D. Now sometimes when I open the sheet, there will be a progress bar calculating formulas in this sheet, which could take around 2 mins, even though I have only like 5 testing orders in the sheet. I am afraid this will get worse when I have more datas or when it is open by old computers.
Is it because I use some resource consuming functions? Can it be improved?

Select corresponding value from max value in a column for current week

In google sheets, I have created the the table below:
Current Week:
4/12/21 (represented by: =TODAY()-WEEKDAY(TODAY(),3))
Most availability for current week:
Person 1
Team Member
4/12/21
4/19/21
Person 1
10%
25%
Person 2
5%
50%
What I am trying to do:
For the current week's column, automatically determine the max value and return the Team Member's name.
What I used thus far:
=INDEX(A8:A,MATCH(MAX(B8:B),B8:B,0))
This formula makes me manually select the column, I am hoping to have the column selected automatically based on the current week, which is why I have it represented above the table as it's own cell using the formula to identify the current week. Can this be done?
Assuming your table header row is 7 then this formula may work:
=INDEX(A8:A,MATCH(MAX(FILTER(B8:C,B7:C7=TODAY()-WEEKDAY(TODAY(),3))),FILTER(B8:C,B7:C7=TODAY()-WEEKDAY(TODAY(),3)),0))

Count items in column range if value exists in corresponding row ranges

I have a spreadsheet which tracks weekly meeting attendance. I need to return the number of individuals who attended at least one meeting in the month, not the sum total of weekly meeting attendees. In other words, if a person attended 4 meetings in the month, the count is incremented by 1, not 4.
Names are listed in Column A, and the weeks in the month are listed in columns B-F (e.g. B2 is "Sep 2"; C2 is "Sep 9"; "D2 is "Sep 16", and so on.) When a person attends a meeting, the corresponding cell receives an "X".
So far, the only method I know I can use to return the number of unique or distinct meeting attendees is to first use a set of formulas in one column (H) to return whether an "X" is found in the corresponding rows, and then a second formula that references the range (in column H) containing the first set of formulas to return the number of TRUE results.
What I'm trying to do is use an ArrayFormula or something similar to give me the final number in just one shot. I'm currently using a COUNTIF function on values in a column range while the rows in that very range are populated using COUNTA functions.
How can I use just one formula to return the attendance count - not depending on that intermediary step/range in column H?
I can't seem to get an array formula to work correctly, and I haven't been able to find similar answers despite hours of searching. Apologies if there are similar questions already posted (I couldn't find one asking quite the same question as mine). Here's my best attempt so far:
=ArrayFormula(COUNTIF(COUNTA(B3:F17) > 0,TRUE)) ...which returns 1.
Here is an example spreadsheet with sample data.
In I22 I entered this formula
=countif(ArrayFormula(countif(if(B3:F17="X", row(B3:B17)), row(B3:B17))), ">0")
the formulas in H3:H17 are not used in this formula.
See if that works?

Combining the select clause in query function with Indirect function. - Google Spreadsheets

So basically I need a dynamic select statement which changes references when dragged across rows or columns.
Example of what I need.
=sum(query('Sheet1'!$A$1:$F$621, Indirect("Select"&$F&"Where A='ABC' AND B="&"Sheet2!"&$A1)))/20
Sample Sheet 1 (Data Sheet)..--Since I am not allowed to use images till i reach rep 10 lol :)
Column 1 - Sales Sites (ABC, DEF, GHI.....)
Column 2 - Sales Roles (SM, ASM, SE.....)
Column 3 - Sales in Month Jan
Column 4 - Sales in Month Feb
Column 5 - Sales in Month Mar
Sample Sheet 2 (Desired Output)
Description (in pivot terms):
Site wise (filter)
Role wise (Rows)
Month wise (Columns - Sum of Jan, Feb etc)
Value (Sum of Jan/20)--To get day wise sales numbers
FYI:
I have tried using pivots, but google spreadsheets don't allow use of calculated fields in pivots in any manner (for the /20 in the formula), hence trying to achieve the same results by formula.
I know a table on the basis of the pivot table could help solve this problem, but to make it more efficient I am trying to avoid using 2 tables.
Many Thanks for your help in advance, please let me know if you need additional info to understand the scenario.

Resources