Google sheets conditional formatting of lowest n - google-sheets

I keep sheets with scores for players, and the 10 lowest scores are counting.
What I would like to do is to color the 10 first lowest scores in light green.
The last highest number of those 10 in darker green. (It's the score to beat in order to improve your total score) And the lowest score in yellow.
I guess it is easier to explain with an example:
https://docs.google.com/spreadsheets/d/1BSGfpzmaibsR4dxHqFgmYmJq7RtyAEV8uRCB0S3Fa4A/edit?usp=sharing
Feel free to copy your own set and try out:)

The solution was to get Rank without ties, and this would give you Rank without ties:
=RANK(B2,$B2:2,1)+COUNTIF($B2:B2,B2)-1
With correct rank it's easy to add custom formatting for the highest of the 10 lowest:
=RANK(B2,$B2:2,1)+COUNTIF($B2:B2,B2)-1=10
Since it works on a range, B2 in the formula will be substituted for each cell in the range.
So the problematic cell O4 will give:
RANK(O2,$B2:2,1) equals 10
COUNTIF($B2:O2,O2) equals 2
so
RANK(B2,$B2:2,1)+COUNTIF($B2:B2,B2)-1 equals 11 ie it will not be colored
Had to add an extra condition to color the highest scores for players with less than 10 scores.

The closest I can get quickly is with 3 rules:
1: Lowest:
=QUERY(QUERY(TRANSPOSE(B2:Q2),"SELECT Col1 ORDER BY Col1 DESC LIMIT 10"),"SELECT MIN(Col1) LABEL MIN(Col1) ''")
2: Highest:
=MAX(B2:Q2)
3: Then a between:
=QUERY(QUERY(TRANSPOSE(B2:Q2),"SELECT Col1 ORDER BY Col1 DESC LIMIT 10"),"SELECT MIN(Col1) LABEL MIN(Col1) ''")+1
&
=MAX(B2:Q2)-1

Related

Count Specific Item Names in Cell

I'm trying to count the instances of which the items have been added to each cell.
Please refer the screenshot.
I need to Count how many:
SIGMA CANON LENS
SIGMA NIKON LENS
SIGMA SONY LENS
are there in the column. Please help me on ow to get this done
try:
=INDEX(QUERY(FLATTEN(SPLIT(TEXTJOIN(CHAR(10), 1, A2:A), CHAR(10))),
"select Col1,count(Col1) group by Col1 label count(Col1)''"))

Arrayformula to calc sum for dynamic offset range

I'm trying to calculate values with an arrayformula, based on the last 14 days (the last 14 rows, since every row is 1 day).
I want N110:N to have the values (in example: sum) from, let's say, I96:I110.
Means, the values in N110 should be sum(I96:I110). For N111 it should be sum(I97:I111) etc.
I have something like = ARRAYFORMULA("I"& Row(I110:I)-14 & ":I" & Row(I110:I)) which returns
I96:I110
I97:I111
I98:I112
...
in each row.
I cannot wrap this into the arrayformula, since Indirect() is not working here and is returning only the first value.
I also tried with offset, which led to the same result.
Basically I'm trying to use an arrayformula to calc values by a dynamic offset range with a fixed size (14).
I could solve it with google apps script, but I want to try with arrayformula.
try:
=INDEX(IFNA(VLOOKUP(ROW(A1:A),
QUERY(SPLIT(FLATTEN(ROW(A1:A)&"×"&ARRAY_CONSTRAIN(
SPLIT(FLATTEN(QUERY(TRANSPOSE(IF(ROW(A1:A)<=TRANSPOSE(ROW(A1:A))=TRUE,
TRANSPOSE(A1:A)&"×", )),,9^9)), "×"), 9^9, 14 +N("14 day window"))), "×"),
"select Col1,sum(Col2)
where Col2 is not null
group by Col1"), 2, )))
Make sure that N110:N is empty, and then place the following formula in N110:
=ArrayFormula(IF(I110:I="",,SUMIF(ROW(I96:I),"<="&ROW(I110:I),I96:I)-SUMIF(ROW(I96:I),"<="&ROW(I110:I)-15,I96:I)))
This formula assumes that there are no blank cells interspersed between numbers in I96:I (though there may be blank cells after the number list runs out).
Essentially, this sums all cells in in the range up to the current row and then subtracts the total of all cells in rows prior to "15 cells back" as marked from the current cell.

How to find the value in a cell after consecutive positive numbers

I have a list here of numbers, positive and negative, from A3:A17. I want to find the value after a consecutive streak of positive numbers. So in the picture above, there's a streak of two consecutive positive numbers from A5 to A6, 2.60% and 1.10%, respectively. I want to get the number after that, which is -1.90%. But if there's another streak of two positive numbers, I want the formula to be able to identify that too. I have a formula to identify the streak but not one to identify the number that comes after it.
Try these in cell B3 (deleting everything below):
Any occurrences:
=arrayformula(if(A3:A<0,if(A2:A>0,if(A1:A>0,A3:A,),),))
2 occurrences:
=arrayformula({"";if(A4:A<0,if(A3:A>0,if(A2:A>0,if(A1:A<0,A4:A,),),),)})
3 occurrences:
=arrayformula({"";"";if(A5:A<0,if(A4:A>0,if(A3:A>0,if(A2:A>0,if(A1:A<0,A5:A,),),),),)})
4 occurrences:
=arrayformula({"";"";"";if(A6:A<0,if(A5:A>0,if(A4:A>0,if(A3:A>0,if(A2:A>0,if(A1:A<0,A6:A,),),),),),)})
=ArrayFormula(QUERY(IF(A3:A>0,IF(A4:A>0,A5:A,),),"select Col1 where Col1 is not null",0))
Try this in cell B3 and autofill downward:
=IF(A1>0,IF(A2>0,A3,""))

Google Sheets help - How to apply COUNTIFS with different size criteria ranges

I understand that for COUNTIFS, you need to have ranges that are the same size and shape. However, I need one condition to be that the ID# in the cell matches the ID # in a one column range AND that the age in the cell matches the age value in a five column range. How can I work around this?
Sample sheet: https://docs.google.com/spreadsheets/d/1i6qFmJ1t7yDpGVSO8YOPnWqW_OZEz6fv4shTOBO-q3M/edit?usp=sharing
In cell A7 of the 'Analysis' tab I entered
=query(ArrayFormula(regexreplace(split(flatten(Masterfile!A2:A&"_"&Masterfile!B2:F), "_")&"", "\d+\smonths", "0")), "Select Col1, count(Col1) where Col2 <>'' group by Col1 pivot Col2")
See if that works for you?

Create a column with numbers from 0 to 1000 in increments of 10

I am new to google sheets and am unaware of how to create a sequence of numbers in a column. I want to create a column with numbers from 0 to 1000 in increments of 10
Method 1 (formula)
Copy the following formula =(ROW()-1)*10
Select cells A1:A100
Paste the formula.
Method 2 (fill down series):
Write 0 on A1
Write 10 on A2
Write 20 on A3
Select A1:A3
Click on the bottom right corner of A3, then drag down until A100.
=ARRAYFORMULA({0; ROW(A1:A100)&0})
or:
=ARRAYFORMULA({0\ ROW(A1:A100)&0})
if you want real numbers then use:
=ARRAYFORMULA({0; VALUE(ROW(A1:A100)&0)})
or:
=ARRAYFORMULA({0\ VALUE(ROW(A1:A100)&0)})

Resources