I'm working on a timetabling project on Google Sheets. I am making the student timetables at the moment.
There is a teacher overview sheet stating which teacher is in which room for which class. I am need a formula that can return a class code, room, and teacher in the period slot. Each period is a column.
The OVERVIEW sheet
MONDAY
Teacher Period 1 Period 2 Period 3 Period 4 Period 5
Teacher 1 07MA01 # BG01 08MA01 # BG01 09MA01 # BG01 10MA01 # BG01 11MA01
Teacher 2 11EN01 # B101 07EN01 # B101 08HU01 # B101 09EN01 # B101 10EN01 # B101
Teacher 3 08FR01 # B201 10FR01 # B201 07FR01 # B201 11FR01 # B201 09FR01 # B201
Teacher 4 FREE FREE 10GG01 # B102 08HU01 # B102 08HU01 # B102
The Student Timetable sheet
Student 1
Contact:
student1#example.com
Classes (input)
student1
Period 1
Period 2
Period 3
Period 4
Period 5
After School
08HU01
Monday
Teacher 1
Teacher 2
Teacher 4
Teacher 4
08MA01
FREE
08MA01
08HU01
08HU01
08HU01
BG01
B101
B102
B102
Tuesday
FREE
FREE
FREE
FREE
FREE
Wednesday
FREE
FREE
FREE
FREE
FREE
Thursday
FREE
FREE
FREE
FREE
FREE
Friday
FREE
FREE
FREE
FREE
FREE
The example sheet
On the student timetable sheet, the administrator can enter any class code in column I. For example, 08HU01 and 08MA01. The formula searches for Column I input matches in overview sheet and outputs it in the time slot exB3:B5
| B
----------------
3 | teacher
4 | class code
5 | room
I tried vlookup but it doesn't support searching for multiple values and ranges:
=VLOOKUP(I2:I3[other things],OVERVIEW!B3:F6,1,1)
Paste this formula in B3, B6, B9 B13 B15 and change the day table for day week.
=ArrayFormula(TRANSPOSE(SPLIT(TRANSPOSE(
LAMBDA(g, IFNA(BYCOL(B$2:F$2, LAMBDA(lr, TEXTJOIN(",",1,VLOOKUP(lr, g, {2,4,3},0)))), " ,Free, "))
(LAMBDA(fl, TRANSPOSE(SORT(TRANSPOSE(fl), SEQUENCE(COUNTA(QUERY({TRANSPOSE(fl)}, "Select Col1")), 1,1,1),0)))
(IFERROR(TRIM(SPLIT(FLATTEN(SPLIT(
LAMBDA(t, BYROW(I2:I, LAMBDA(q, TEXTJOIN(", ", 1 ,QUERY({t}, " Select * where Col1 = '"&q&"' ")))))
(LAMBDA(mr, { mr,IF(SEQUENCE(ROWS(mr), 1,1,1)="",,"+")})
(LAMBDA(y,
{ TRIM(SPLIT(LAMBDA(x, QUERY({x}, "Select Col3 "))
(y), "#")),QUERY({y}," Select Col2,Col1 ")})(SPLIT(FLATTEN(OVERVIEW!$B$2:$F$2&"+"&OVERVIEW!$A$3:$A$6&"+"&OVERVIEW!$B$3:$F$6),"+")))), "+")), ", ", 0)), "")))), ",")))
Phew, this didn't seem complicated at the beginning.
Related
Here's my table:
Exchange No.
Name
Tier
30d Volume (higher than)
Maker
Taker
Specials
1
FTX
1
$0
0.0200%
0.0700%
FTX
2
$2,000,000
0.0150%
0.0600%
FTX
3
$5,000,000
0.0100%
0.0550%
FTX
4
$10,000,000
0.0050%
0.0500%
2
Binance
Regular User
$0
0.0120%
0.0500%
Binance
VIP 1
$15,000,000
0.0120%
0.0500%
Binance
VIP 2
$50,000,000
-0.0100%
0.0500%
I want to retrieve the correct fees in another table as follows:
Volume (past 30d):
volume variable, ie $10,000
FTX
Binance
Column #
2
3
4
IN:
Maker
correct fee
correct fee
OUT-stop:
Maker
correct fee
correct fee
OUT-profit:
Maker
correct fee
correct fee
OUT-manually:
Maker
correct fee
correct fee
B3 cell (second table) should take the fee in cell E2 (of the first table).
Why?
Cause:
C1 (of second table) says "FTX" as per column B row 2:5 (of first
table)
Volume (in B1 of second table) is higher than D2 but lower than D3 (of first
table)
B3 (of second table) says "Maker" which is column F (of first
table)
So I tried to do a vlookup but only my criteria No. 3 would work with vlookup.
Other criteria are a range higher than (No. 1) and two different columns as "index" (in vlookup formula) which are, by the way, the searched text... (No. 2)
Someone has an idea to take into account those special criteria in vlookup, or similar, please?
try:
=INDEX(VLOOKUP(M2, QUERY({'Exchange Fees'!B2:B&":", 'Exchange Fees'!D2:D,
FILTER('Exchange Fees'!A2:G, 'Exchange Fees'!A1:G1=M3)},
"select Col2,Col3 where Col1 = '"&N2&"'", ), 2, 1))
I have been able to use Google Sheet's SEQUENCE formula to provide me with sequenced dates for Partner 1 but then the formula stops and doesn't move on to Partner 2.
I have tried nesting within an Google's ArrayFormula but still cannot get it to function properly.
I'd like to avoid having to do each partner manually then copying and pasting each partner below the other.
Formulas I've tried:
For creating partner repeats based on number of days
=ARRAYFORMULA(TRIM(TRANSPOSE(SPLIT(QUERY( REPT($L$3:$L$16&",",$Q$3:$Q$16),,2^100),","))))
For sequencing dates, but only does the first range
=ARRAYFORMULA(TO_DATE(SEQUENCE(Q3,1,O3)))
CURRENT DATA
| Partner| Start Date| End Date | Total Days|
|:-------|:---------:|:--------:|----------:|
|Partner1| 3/1/2021 | 3/8/2021| 7 |
|Partner2| 3/1/2021 | 3/9/2021| 8 |
WANTED FORMAT
Partner Date
Partner 1 3/1/2021
Partner 1 3/2/2021
Partner 1 3/3/2021
Partner 1 3/4/2021
Partner 1 3/5/2021
Partner 1 3/6/2021
Partner 1 3/7/2021
Partner 1 3/8/2021
Partner 2 3/1/2021
Partner 2 3/2/2021
Partner 2 3/3/2021
Partner 2 3/4/2021
Partner 2 3/5/2021
Partner 2 3/6/2021
Partner 2 3/7/2021
Partner 2 3/8/2021
Partner 2 3/9/2021
You can do it generally by doing a vlookup of sequence number in the cumulative sum of the days.
For partner:
=ArrayFormula(vlookup(sequence(sum(D2:D),1,0),{sumif(row(D2:D),"<"&row(D2:D),D2:D),A2:A},2,true))
For date:
=ArrayFormula(to_date(sequence(sum(D2:D),1,0)
-vlookup(sequence(sum(D2:D),1,0),sumif(row(D2:D),"<"&row(D2:D),D2:D),1,true)
+vlookup(sequence(sum(D2:D),1,0),{sumif(row(D2:D),"<"&row(D2:D),D2:D),B2:B},2,true)))
You can use the following formula
=INDEX({SPLIT(A2&"#"&SEQUENCE(C2-B2,1,B2),"#");
SPLIT(A3&"#"&SEQUENCE(C3-B3,1,B3),"#");
SPLIT(A4&"#"&SEQUENCE(C4-B4,1,B4),"#")})
If still having issues, please share more info.
(do adjust ranges and locale syntax to meet your needs)
I have 2 different Google Sheets. Master Sales & Projections. On Master Sales I have 2 columns, Expected & Billed which has data broken down by billing weeks.
I need Sheet 2 to grab the data from the cell that not 0 since we are trying to track total sales for the month (expected & actual) and then at the end of the month we would have the real billed numbers.
Potato example below
Sheet 1
A B
1 Expect Billed
2 $123 $145
3 $145 $155
4 $156 $0
5 $132 $0
What Sheet 2 should look like
A B
1 Week1 $145
2 Week2 $155
3 Week3 $156
4 Week4 $132
Assuming you will arrange for the week numbers, in B1 please try:
={query(Sheet1!A2:B5,"select B where B<>0",0);query(Sheet1!A2:B5,"select A where B=0",0)}
I've got a Google Sheet which holds the results of a monthly competition. The format is
Name | Date | Score
--------------------------------
Alan Smith | 14/01/2016 | 500
Bob Dow | 14/01/2016 | 450
Bob Dow | 16/01/2016 | 470
Clare Allie| 16/01/2016 | 550
Declan Ham | 16/01/2016 | 350
Alan Smith | 10/02/2016 | 490
Bob Dow | 10/02/2016 | 425
Declan Ham | 12/02/2016 | 400
Declan Ham | 12/02/2016 | 390
Clare Allie| 12/02/2016 | 560
I want to do 2 things with this data
I want to create a new sheet which holds the latest 'best' results. For the data presented here that would be
Alan Smith | 10/02/2016 | 490
Bob Dow | 10/02/2016 | 425
Declan Ham | 12/02/2016 | 400
Clare Allie| 12/02/2016 | 560
i.e. The results from February with the 'best' score per person. Here Declan Ham's lower score of '390' was removed.
I want another sheet to hold the tournament ranking. People are ranked by their top 3 monthly scores. i.e. The best score for each person for each month is obtained and the top 3 scores are combined to give their place in the tournament.
So far I've attempted to use Google queries, vlookups, filters to get these new sheets. But, just focusing on 1), the best I've been able to achieve is
=FILTER(Results!$A:$B, MONTH(Results!$B:$B) = MONTH(MAX(Results!$B:$B)))
Which will get me the results from the latest month. But it does not remove duplicates entries by people.
Does anyone have a suggestion for how I can achieve these requirements? Feel like I'm treading water at the moment.
Rather than trying to remove duplicates, you need to identify the maximum score by each person; you can do that by grouping values by person, then aggregating using max(). Here's how that would look, for the month of February 2016:
=query(Results!A1:C,"select A,max(C) where todate(B) > date '2016-2-1' group by A")
Instead of using a fixed value for the start of the latest month, we can get the year and month using spreadsheet formulas, and concatenate our query with them:
=query(Results!A1:C,"select A,max(C) where todate(B) > date '"&year(max(Results!B2:B))&"-"&month(max(Results!B2:B))&"-1' group by A")
That addresses your first question.
Tournament ranking
Your second goal is too complex for a single spreadsheet formula, in my opinion. Here's a way to accomplish it with multiple formulas, though!
The X & Y axes are filled out by spreadsheet formulas. On the X axis (orange), we populate participants names using this in cell A3:
=unique(Results!A2:A)
The Y axis consists of dates (green). These are the start dates of each unique month that there are scores for, calculated using the following formula in cell D2. This results in strings, e.g. 2016-01-1, and that format is specifically required for the later formulas to work.
=TRANSPOSE(SORT(UNIQUE(ARRAYFORMULA(TEXT(Results!B2:B13,"YYYY-MM-1")))))
Here's the formula for cell D3, which will calculate the sum of the 3 highest scores recorded for the user whose name appears in A3, for the month appearing in D2. (Copy & Paste the formula across the full range of participants & months, and it will adjust.)
=sum(query(Results!$A$1:$C,"select C where A='"&$A2&"' and todate(B) >= date '"&B$1&"' and todate(B) < date '"&IF(ISBLANK(C$1),TEXT(TODAY()+1,"yyyy-mm-dd"),C$1)&"' order by C desc limit 3 label C ''"))
Key points about that formula:
The query range needs to used fixed values so it isn't transposed when copied to additional cells. However, it's still open-ended, to absorb additional rows of scores on the "Results" sheet.
Results!$A$1:$C
A WHERE clause is used to select rows from the Results sheet that are for the given participant (A='"&$A2&"') and fall within the month that heads the column (C$1).
...and todate(B) < date '"&IF(ISBLANK(C$1),TEXT(TODAY()+1,"yyyy-mm-dd"),C$1)&"'
The best 3 scores for the month are found by first sorting the above result descending, then limiting the result to 3 rows.
...order by C desc limit 3
Finally, the QUERY headers are suppressed by this little trick, so that we get a single number as the result:
...label C ''
Individual tournament totals appear in column C, with a range SUM across the row, e.g. for cell C3:
SUM(D3:3)
The corresponding ranking in column B is then:
RANK(C3,C$3:C)
Tidy
For simpler copy/paste, you can do some error checking in these formulas, so that they can be placed in the sheet before the corresponding data is - for example, at the start of your season. Using IF(ISBLANK(... or IFERROR(... can be very effective for this.
B3 & down:
=IFERROR(RANK(C3,C$3:C))
C3 & down:
=IF(ISBLANK(A3),"",sum(D3:3))
D3 & rest of field:
=IFERROR(sum(query(Results!$A$1:$C,"select C where A='"&$A3&"' and todate(B) >= date '"&D$2&"' and todate(B) < date '"&IF(ISBLANK(E$2),TEXT(TODAY()+1,"yyyy-mm-dd"),E$2)&"' order by C desc limit 3 label C ''")))
Alternatively for the first part of your question (the latest 'best' results) , in addition to the solution provided by Mogsdad, this should also work.. :-)
=ArrayFormula(iferror(vlookup(unique(A2:A), sort(A2:C, 2, 0, 3, 0), {1,3}, 0)))
EDIT: This formula sorts the table with dates (col B) descending and col C descending and then (ab)uses the fact that vlookup only returns the first match to return the first and last column.
I need a SUMIFs equivelent in google spreadsheet. It only has SUMIF, no IFS.
here is my data:
# Salesman Term (Month) Amount
1 Bob 1 1,717.09
2 John 1 634.67
3 Bob 1 50.00
4 Bob 1 1,336.66
5 Bob 1 0.00
6 Bob 1 55.00
7 Bob 300 23,803.97
8 Bob 300 24,483.91
9 Bob 300 20,010.03
10 Bob 300 41,191.62
11 Bob 300 40,493.14
12 Bob 300 10,014.01
13 John 1 100.00
13 John 100 100.00
I want to add everything that BOB sold that the term is equal to or less then 100. I also want to SUM everything that bob sold that the term is greater then 100. Same for John.
You need to use the FILTER function combined with the SUMfunction. In your example with Bob, your function would be like (assuming your data columns is from A to C):
=SUM(FILTER(C:C;A:A="Bob";B:B<=100))
The new Google Spreadsheet, now has the SUMIFS function available.
You can use the following formula:
=SUMIFS(F1:F14,D1:D14, "=Bob",F1:F14, ">=100",E1:E14, "<100")
If you want to perform the calculation for John as well, I can recommend the following:
=QUERY(D1:F14, "SELECT D, SUM(F) WHERE E<100 AND F>=100 GROUP BY D LABEL D 'Who', SUM(F) 'Total'")
See example file I created: SUMIFS on DATA