How to extract a handicap value from column based on 2 criteria - arrays

Good morning,
I have an issue with extracting the correct handicap value within the following table:
K L M
Handicap York Hereford
0 1287 1280
1 1285 1275
2 1280 1271
3 1275 1268
4 1270 1265
5 1268 1260
6 1265 1258
7 1260 1254
8 1255 1250
9 1253 1246
I also have these 2 lines of sample score/round data:
G H I
Round Score Handicap
York 1269 5
York 1270 4
Hereford 1269 XXX
Hereford 1270 XXX
If for instance someone on a York, gets a score of 1269, they should get a handicap of 5, which this formula achieves:
INDEX($K$7:$K$16,MATCH($H7,$L$7:$L$16,-1))+1
However this formula only works on the one column $L$7:$L$16
Similarly, the 2ns score is calculated with the following formula:
=INDEX($K$8:$K$17,MATCH($H8,$L$8:$L$17,-1))
What I'd like to do is, build that out so if I changed the round to a Hereford, with the exact same score, the cell would automatically calculate that the handicap should be 3.
Is this possible, maybe with an array?
Regards,
Andrew.

With ms365, try:
Formula in I2:
=XLOOKUP(H2,FILTER(L$2:M$11,L$1:M$1=G2),K$2:K$11,"NB",-1,-1)

I would avoid using OFFSET because it is a volatile function.
To select the appropriate column, you can use another MATCH:
MATCH($G7,$L$6:$M$6,0)
will return the column number. This makes it simple if you more than just York and Hereford columns.
Then, to return the matching line:
=MATCH($H7,INDEX($L$7:$M$16,0,MATCH($G7,$L$6:$M$6,0)),-1)
Note the use of 0 for the Row argument in the INDEX function which will return the entire column (all the rows).
Since your handicaps are sequential, as written this formula returns the same values as does yours. But I don't think it is correct since both formulas return 1 for a 1287 York.
You probably need to subtract one from the result of the formula.
=MATCH($H7,INDEX($L$7:$M$16,0,MATCH($G7,$L$6:$M$6,0)),-1)-1

Reference your lookup range with an OFFSET() function, and for the third parameter (which is column offset), use a MATCH() on the headers.
The formula on your first row would be:
=INDEX($K$7:$K$16,MATCH(H7,OFFSET($L$7:$M$16,0,MATCH(G7,$L$6:$M$6,0)-1,ROWS($L$7:$M$16),1),-1))+1

Related

Query min column header while excluding blanks and handling duplicates

I have the following table.
Name
Score A
Score B
Score C
Bob
8
6
Sue
9
12
9
Joe
11
2
Susan
7
9
10
Tim
10
12
4
Ellie
9
8
7
In my actual table there are about 2k rows.
I am trying to get the min score (excluding blanks & handles duplicate scores) for each person into another column using the QUERY formula or ARRAYFORMULA, really to avoid entering a formula for each row.
As I do currently have this
=INDEX($B$1:$D$1,MATCH(MIN(B2:D2),B2:D2,0))
But that involves dragging down through each cell, as I do this on a few sheets that have circa 2k rows, it's very slow when inputting new data.
This should be the end result
Name
Score A
Score B
Score C
Min Score
Bob
8
6
Score C
Sue
9
12
9
Score A
Joe
11
2
Score B
Susan
7
9
10
Score A
Tim
10
12
4
Score C
Ellie
9
8
7
Score C
use:
=INDEX(SORTN(SORT(SPLIT(QUERY(FLATTEN(
IF(B2:D="",,B1:D1&"×"&B2:D&"×"&ROW(B2:D))),
"where Col1 is not null", ),
"×"), 3, 1, 2, 1), 9^9, 2, 3, 1),, 1)
The following answer employs three of the newest set of functions that are still being rolled out by Google so you might not be able to use it right now, but in a few weeks when they're fully rolled out you definitely will (this worked using the Android version of Sheets just now for me):
=arrayformula(if(len(A2:A),byrow(B2:D,lambda(row,xlookup(min(row),row,B1:D1))),))
Assuming the names are in column A, this should give a result for every row which has a name in it. I'm sure there are other ways of doing this, but these 'row/column-wise' problems are really ideal use-cases for LAMBDA and its helper functions like BYROW.

How do you count cells using regex that do not match the expression?

I want to count the number of cells that do not contain the following words.
denv
univ
du
The above list of words change frequently and in Cell B22 it automatically creates some regex for another formula where I sum another column next to it.
Cell B22 = .*denv.*|.*univ.*|.*du.*
Can I use the same Cell B22 reference for counting everything that DOES NOT contain those words?
Name
Metric
denver
5
ohio
5
dual
9
dual
1
maryland
4
universe
6
maryland
1
dual
2
denver
7
try:
=INDEX(SUMPRODUCT(REGEXMATCH(FILTER(A:A, A:A<>""), B22)=FALSE))
or:
=SUM(INDEX(N(REGEXMATCH(FILTER(A:A, A:A<>""), B22)=FALSE)))

Working off of the results of 2 Conditional Formats

Another ? for you. How can I work off of the results of 2 Conditional Formats & have just the results of those conditions highlighted. The 2 Conditional Formats results are in (column C & G) & I need to have the results highlighted in (column A)... A's 3 arguments are as follows:
condition1 cell value equal to 0, No Format
condition2 formula is =$G27>=LARGE($G$27:$G$150,10), Bold Format
condition3 formula is =$C27>=LARGE($C$27:$C$150,10), Colored Red
Another quandry...
This is just like the fizzbuzz programmer test.
So, without writing the code for you: I'll recommend a loop through a 'listobject(table)' followed by setting the range values using '.interior.colorindex' or 'font.colorindex' properties.
OK, without using code...
- Format your table as a table using "Format as Table" function
- In the "Table" menu, select the "Total Row" checkbox
- Set your Total formula for Cols C and G as =LARGE([ColC],10) and =LARGE([ColG],10), respectively.
- In Conditional Formatting, set up two rules as follows:
- =$B28>=$D$[TotalRowlNumber]
- =$B28>=$C$[TotalRowNumber]
- You shouldn't need a condition for =0 since you are not changing any formats.
How does that work?
Here's a sample table:
ID Col A Col C Col G
____________________________
1 50.66 51.33 97.17
2 16.09 83.39 97.37
3 b71.94 69.77 28.06
4 21.60 20.59 21.14
5 33.62 65.58 39.21
6 21.96 34.59 17.99
7 br80.94 93.02 96.84
8 b70.53 37.53 29.60
9 32.06 37.38 0.15
10 br89.81 67.02 6.85
11 br89.76 64.65 74.00
12 47.94 46.06 1.71
13 b61.19 34.19 90.13
14 br79.11 35.77 86.97
15 39.89 79.15 77.88
16 br93.20 8.01 13.99
17 31.84 18.12 95.61
18 br99.78 19.99 3.89
19 38.94 32.12 18.56
20 13.17 22.23 61.82
21 br75.75 51.42 28.32
22 b55.89 49.93 76.30
23 br72.78 82.46 27.07
24 b57.20 31.26 76.90
25 6.46 6.85 2.78
Total 51.33 74.00
Use the LARGE() formula to get the 10th largest value in the TOTAL row.
Then reference this cell in the condition.
So, any number larger than 51.33 will be bold and any number larger than 74.00 will be bold red. (Note, I used random number generator, so the numbers may be good or bad.)
Also, I added a 'b' tag and an 'r' note where cells will be formatted bold and red, respectively.

Exclude blank/FALSE cells in in Excel array IF formula output

I am having difficulties with making an array formula work the way I want it to work.
Out of a column of dates which is not sorted, I want it to extract values into a new column. The formula below identifies the required cells of a given month and year, but they appear in their original row rather than on top of the output range. Moreover, I want all ""/FALSE cells to be excluded from the output array.
=IF((MONTH($I$15:$I$1346)=1)*(YEAR($I$15:$I$1346)=2008),$I$15:$I$1346,"")
In fact, the $I$15:$I$1346 should be dynamic and go to the last filled range (I could make a named range for that)
Part two is to expand on that formula so that it calculates the data that is an two column offset of the data described above.
Is the above possible to build into one cell probably with a combination of IF, INDEX, SMALL and maybe others?
I'm not looking for a filter solution. Hope the above is clear enough and that you can help!
Here's a shortened sample layout:
A B C
1 Date Series_A Series_B
2 03/01/2011 45 20
3 04/01/2011 73 30
4 06/01/2011 95 40
5 08/01/2011 72 50
6 06/02/2011 5 13
7 09/02/2011 12 #N/A
8 05/02/2011 23 65
9 07/03/2011 12 65
Then I want three input cells for the year and and the month and series name (index/match, as there are many more columns with data). If it would be 2011, Feb and Series_A, I want it to calculate the average for that month. In this case it would be (5+12+23)/3. If it would be Feb-2011 and Series_B instead, which has an error, it should show (13+65)/2 rather than an error.
Aside from that I want a separate which will output an array with the data instead without 'holes' in between and with the right 'length'. Example for Feb-2011 in Column C:
A B C D
1 Date Series_A Desired Output Output based on f above
2 03/01/2011 45 5
3 04/01/2011 73 12
4 06/01/2011 95 23
5 08/01/2011 72
6 06/02/2011 5 5
7 09/02/2011 12 12
8 05/02/2011 23 23
9 07/03/2011 12
If I then run a =ISBLANK(C5) it should be true, rather than =""=C5
Hope the edit clarifies
I reached out to various platsforms to get an answer, and here you have one which is ok. Still doesn't fully answer part 1, but works nonetheless.
http://www.excelforum.com/excel-formulas-and-functions/905356-exclude-blank-false-cells-in-in-excel-array-if-formula-output.html

How can I lookup a column value based on a percentage that must match a range specified in the same row as the return value?

I am a lecturer and am trying to build a mini grading spreadsheet that based on the points given to a student will calculate a percentage value describing their grade and I now want to assign the appropriate grade to a student's column in Sheet1 so that it reads
50%
C-
I have created a matrix of the range identifiers and the text value of the grade on Sheet2 which looks like this:
A B C
1 A++ 95 100
2 A+ 90 94.5
3 A 85 89.5
4 A- 80 84.5
5 B+ 75 79.5
6 B 70 74.5
7 B- 65 69.5
8 C+ 60 64.5
9 C 55 59.5
10 C- 50 54.5
11 D 0 49.5
Column A holds the string describing the grade,
Column B is the start of the range,
Column C is the end of the range for a given grade.
On Sheet1 I run through all the basic calculations which returns me with a single percentage value to match against this matrix, let's call the field of this value Sheet1!A1 for now.
What I in essence want to do is loop through the rows 1-11 of Sheet2 and do this:
IF ( Sheet1!A1 >= Sheet2!B1 AND Sheet1!A1 <= Sheet2!C1 ) THEN RETURN Sheet2!A1
Can this be done? I've read through all the supporting documentation and have not been able to find a way to do this yet.
Any help would be much appreciated.
Many thanks for reading,
Jannis
Anand Varma just replied to the same question posted on the Google Forums with the solution so for completeness I will post his answer here as well.
The original answer on the Google Forums is here.
The solution was using the INDEX function with the MATCH function inside of it:
=INDEX( Sheet2!$A$1:Sheet2!$A$11, MATCH( C41, Sheet2!$C$1:Sheet2!$C$11, -1 ) )
C41 refers to the cell that holds the numerical source value to match against.
Thanks Anand.

Resources