combining STDEV & VLOOKUP - google-sheets

I am trying to find the STDEV of a specific teams score based on the seasons completed games.
I want to accomplish this by using vlookup. I came up with this formula but it shoots a DIV/0 error.
=STDEV(vlookup(B19,'2021 Game Log'!A2:B,2,false))
basically now I have the STDEV of ALL AWAY GAMES.... I'd like to refine that and get the STDEV of ONLY the AWAY team that's listed in that games "B cell". The scores are listed in 2021 Game Log. (that make sense?)
https://docs.google.com/spreadsheets/d/1F2t8RDp1qDDoGEMCdYOOxGDlDQHyZNaDQ8nRr7qP3v4/edit?usp=sharing
Here is a screenshot that might help.
https://i.stack.imgur.com/AK1l0.png

the output of your:
=VLOOKUP(B19, '2021 Game Log'!A2:B, 2, 0)
is:
3
eg. it's a single value so it's same as if you would run:
=STDEV(3)
and that translates to error because there is only one value you trying to STDEV
... I believe this is what you need:
=STDEV(FILTER('2021 Game Log'!B2:B, '2021 Game Log'!A2:A=B19))

Related

Select a Value from a Range Based on Criteria from Another Sheet

First, I know this is really stretching what Sheets is meant to do, but here we are.
Sheet 1 is a list of meetings and who is assigned to run them (the larger sheet is extrapolated to many meetings across multiples days with many names):
Day
Activity
Assigned
Covering
Monday
Meeting #1
Smith
?
Monday
Meeting #1
Hansen
?
Monday
Meeting #2
Jones
?
Sheet 2 is who is eligible to be cover the meeting if the assigned employee is out:
Eligible Employee
Coverage Count
Attendance
Exclusion Day
Kelley
0.1
Present
Monday
Johnson
0.2
Absent
Tuesday
Ramirez
0.3
Present
Wednesday
Callahan
0.4
Present
Thursday
Basically, my manager wants a button he can hit to say "Hansen isn't here, who is covering them?"
The following logic would apply to select the correct Eligible Employee:
Coverage Count is the lowest/smallest in the range
Attendance = Present
Day != Exclusion Day
For above, if Hansen needed coverage, the logic would pass Kelley because they can't cover Monday, pass Johnson because they are Absent, and return Ramirez because they have a lower Coverage Count than Callahan.
In addition to returning Ramirez, the macro would also "record" a coverage for Ramirez of +1, so their Coverage Count would now be 1.3. That way if the manager then tried to find coverage for Jones next, Ramirez would not be returned again until everyone other Eligible Employee has covered again.
I'm stumped.
At first I tried using FILTER...
=FILTER(Covering_Emp,Covering_Duty<>"Friday",Dovering_Absence="Present",SMALL(Covering_Count,1))
But
I don't think what I need and
Throwing "“FILTER has mismatched range sizes”
try:
=BYROW(A2:A, LAMBDA(x, INDEX(IFNA(SORTN(
FILTER({F2:F, G2:G}, I2:I=x, H2:H="Present"), 1, 1, 2, 1)),,1)))
I think because of the somewhat recursive nature of this question it's easier to try a simple pull-down formula for it in the first place. So any people who have already been used as cover are excluded from the next round of selection using a countif on column D to add one to their coverage count:
=index(sort(filter({F$2:F,G$2:G+countif(D$1:D1,F$2:F)},H$2:H="Present",I$2:I<>A2),2,1),1,1)
starting in D2 and pulled down.
You can see that Kelley and Johnson are excluded because they are either absent or not available on Monday.

How to check for overlapping dates

I am looking for a solution on either Google sheets or app script to check for overlapping dates for the same account. There will be multiple accounts and the dates won't be in any particular order. Here is an example below. I am trying to achieve the right column "check" with some formula or automation. Any suggestions would be greatly appreciated.
Start Date
End Date
Account No.
Check
2023-01-01
2023-01-02
123
ERROR
2023-01-02
2023-01-05
123
ERROR
2023-02-25
2023-02-27
456
OK
2023-01-11
2023-01-12
456
OK
2023-01-01
2023-01-15
789
ERROR
2023-01-04
2023-01-07
789
ERROR
2023-01-01
2023-01-10
012
OK
2023-01-15
2023-01-20
012
OK
I also found some similar past questions, but they don't have the "for the same account" component and/or requires some sort of chronological order, which my sheet will not have.
How to calculate the overlap between some Google Sheet time frames?
How to check if any of the time ranges overlap with each other in Google Sheets
Another approach (to be entered in D2):
=arrayformula(lambda(last_row,
lambda(acc_no,start_date,end_date,
if(isnumber(match(acc_no,unique(query(query(split(flatten(acc_no&"|"&split(map(start_date,end_date,lambda(start_date,end_date,join("|",sequence(1,end_date-(start_date-1),start_date)))),"|")),"|"),"select Col1,count(Col2) where Col2 is not null group by Col1,Col2",0),"select Col1 where Col2>1",1)),0)),"ERROR","OK"))(
C2:index(C2:C,last_row),A2:index(A2:A,last_row),B2:index(B2:B,last_row)))(
counta(A2:A)))
Briefly, we are creating a sequence of dateserial numbers between the start & end dates for each row, doing some string manipulation to turn it into a table of account number against each date, then QUERYing it to get each account number which has dateserials with count>1 (i.e. overlaps), using UNIQUE to get the distinct list of those account numbers, then finally matching this list against the original list of account numbers to give the ERROR/OK output.
(1) Here is one way, considering each case which could result in an overlap separately:
=ArrayFormula(if(A2:A="",,
if((countifs(A2:A,"<="&A2:A,B2:B,">="&A2:A,C2:C,C2:C,row(A2:A),"<>"&row(A2:A))
+countifs(A2:A,"<="&B2:B,B2:B,">="&B2:B,C2:C,C2:C,row(A2:A),"<>"&row(A2:A))
+countifs(A2:A,">="&A2:A,B2:B,"<="&B2:B,C2:C,C2:C,row(A2:A),"<>"&row(A2:A))
)>0,"ERROR","OK")
)
)
(2) Here is the method using the Overlap formula
min(end1,end2)-max(start1,start2)+1
which results in
=ArrayFormula(if(byrow(A2:index(C:C,counta(A:A)),lambda(r,sum(text(if(index(r,2)<B2:B,index(r,2),B2:B)-if(index(r,1)>A2:A,index(r,1),A2:A)+1,"0;\0;\0")*(C2:C=index(r,3))*(row(A2:A)<>row(r)))))>0,"ERROR","OK"))
(3) Most efficient is to use the original method of comparing previous and next dates, but then you need to sort and sort back like this:
=lambda(data,sort(map(sequence(rows(data)),lambda(c,if(if(c=1,0,(index(data,c-1,2)>=index(data,c,1))*(index(data,c-1,3)=index(data,c,3)))+if(c=rows(data),0,(index(data,c+1,1)<=index(data,c,2))*(index(data,c+1,3)=index(data,c,3)))>0,"ERROR","OK"))),index(data,0,4),1))(SORT(filter({A2:C,row(A2:A)},A2:A<>""),3,1,1,1))
HOWEVER, this only checks for local overlaps. not globally. You can see what I mean if you change the dataset slightly:
Clearly the first and third pair of dates have an overlap but G4 contains "OK". This is because each pair of dates is only checked against the adjacent pairs of dates. This also applies to the original reference cited by OP - here's an example where it would give a similar result:
The formula posted by #The God of Biscuits gives the correct (global) result :-)

How to calculate average based on more factors in google sheets

I have a spreadsheet and I would like to calculate average for each team for 1st half. So, for California, if it's under Home team column, then I should use Home 1st half score column, if it's in Away team column, then Away 1st half score should be used. Currently I have a formula =AVERAGE(AVERAGEIF(C9:C165,C166,E9:E165),AVERAGEIF(D9:D165,C166,F9:F165)) but the problem is if a team has played only away games, then formula throws an error that it can't be divided by 0 because there are no home score results. I would like to calculate average for every team like this.
You can use IFERROR:
=IFERROR(AVERAGE(AVERAGEIF(C9:C165,C166,E9:E165),AVERAGEIF(D9:D165,C166,F9:F165)), AVERAGEIF(D9:D165,C166,F9:F165))
In toher words: If you cannot make and avarage between column C and D because column C si empty - only the average of column D will be returned.
You can nest the formula into a second IFERROR to catch the case when column D is empty.

Formula to create multiple possible results

The spreadsheet I am devising is to help me with the scoring of a football (or soccer depending where you're from) forum game I run. The idea is that each player picks 10 football teams and they get a point for each goal scored. However, they also pick one team which they think will not score any goals. If their team doesn't score they get 3 points but if the team does score they lose a point for every goal the team scores.
For example - Example A) The player picks Man Utd to not score a goal but they score 3. This means that the player would score -3 points. Example B) The player picks Man Utd to not score a goal and they don't. This means that the player would score 3 points.
Is there a way to create a formula for this specific selection to go into cells F13 and J13 which would match the team in the list in Column A to what I have entered in Column D and H and if the score next to this team (in Column B) is "0" it allocates 3 points to the cell F13 and J13 but if the score in Column B is above 0 (eg 3), the value in cell F13 and J13 reads as minus the value shown in Column B (eg -3).
Template spreadsheet can be found here - https://docs.google.com/spreadsheets/d/1DNOVUGPAJF-nR9XtQ1fc-lqm4fYHNBJgz7-rr6SzJaU/edit?usp=sharing (not sure if I have set it correctly to allow editing but if I have then feel free to edit away)
Hope this makes sense!
Please use the following formula on your F13 cell (and all the corresponding ones for the rest of the players)
=IF(-VLOOKUP( D13,$A$2:$B,2,0)=0,3,-VLOOKUP( D13,$A$2:$B,2,0))
You could probably use a single formula on your F1 cell.
=ArrayFormula(IF(C1:C11=TRUE,C1:C11*E1:E11,1))
Functions used:
ArrayFormula
IF
VLOOKUP

Index and Match to find a row header that aligns with variable in specific column

I have been trying to solve this issue, but I need help:
I want to lookup a percentile that matches a certain test score of a student in a certain grade, in a score table.
So the known variables are GRADE LEVEL (Column headers Kinder-gr11), and TEST SCORE.
step 1: lookup the grade level of a certain student,
step 2: lookup the test score of this student,
step 3: result is the matching percentile score (row header).
I cannot get this to work! So frustrating.
Here is a sample Google Sheet:
Click Here
Does anyone have ideas?
try:
=ARRAYFORMULA(INDEX(IFERROR(SPLIT(TRANSPOSE(QUERY(TRANSPOSE(
IF(HLOOKUP(S3:S7, B2:M, TRANSPOSE(ROW(A2:A)), 0)=U3:U7,
TRANSPOSE(N3:N),)),,999^99)), " "), "no match"),,1))
Solved with help from another forum:
=iferror(vlookup(U3,{filter($B$2:$M,$B$2:$M$2=S3),$A$2:$A},2, true))
nb. the table is from the NWEA standardized test scores for MAP testing.
I did not make the table, and I know that there are some of the same scores for various percentiles (depending on how students score sub items of the test which is beyond the scope of my question)
Hans

Resources