How to eliminate highlighting duplicates in google sheets conditional formatting - google-sheets

I have a spreadsheet where I need to conditional format/highlight the lowest 3 scores in a row to reflect dropped scores that are part of a Total calculation. I'm using the SMALL function to successfully calculate the Total..=SUM(A2:I2)-SMALL(A2:I2,1)-SMALL(A2:I2,2)-SMALL(A2:I2,3) but when I try to use the SMALL function in the Custom Formula field of the Conditional Format it highlights 0,60,60,60 and not 0,60,60
119 101 60 100 0 109 60 60 112 TOTAL:601
If four of the values are 0, it will highlight all for 0's.. if 60 is the lowest score and there are 4 or more scores of 60, it will highlight all and not reflect that only 3 of the scores are actually dropped.
Is there another way (custom formula) that can only highlight the lowest 3 scores in the row even when the 3rd lowest may have duplicates in the row?

I've come up with this formula (assuming values start in A1) which unfortunately is a bit long
=OR(A1<SMALL($A1:$I1,3),AND(A1=SMALL($A1:$I1,3),COUNTIF($A1:A1,SMALL($A1:$I1,3))<=(3-COUNTIF($A1:$I1,"<"&SMALL($A1:$I1,3)))))
or
=OR(A1<SMALL($A1:$I1,3),AND(A1=SMALL($A1:$I1,3),(COUNTIF($A1:A1,SMALL($A1:$I1,3))+COUNTIF($A1:$I1,"<"&SMALL($A1:$I1,3))<=3)))
The logic is that it highlights all cells which are less than the third smallest value, then any values (starting from the left) which are equal to the third smallest value until the total equals three.
I've changed the second row to show that it selects the second zero instead of the second 60.

Related

Conditional formatting at row level

I have 2000 rows of cost price data. In each row, I would like to apply a color scale to quickly highlight cost prices (from low to high). However, I would like the color scale comparison logic each time to be applied within a specific row. So row 12 data should not be compared to row 13 data for instance. How can I do this without creating 2000 rules stipulating each row?
I have done it for the first row as below:
D3:BL3
However, when I try $D3:$BL2000 and hit "Done" the $ signs just disappear meaning the formatting logic isn't applied at row level but all rows (so e.g. row 4 is compared to e.g. row 100).
You can't have a conditional formatting with scale color row by row with Google Sheets option. You can simulate it with the help of MIN, MAX and QUARTILE. Here you have an example:
=(D1=MAX($D1:$Z1))*(D1<>"")
=(D1>QUARTILE($D1:$Z1,3))*(D1<>"")
=(D1>QUARTILE($D1:$Z1,2))*(D1<>"")
=(D1>QUARTILE($D1:$Z1,1))*(D1<>"")
=(D1>MIN($D1:$Z1))*(D1<>"")
=(D1=MIN($D1:$Z1))*(D1<>"")
PS: remember to sort accordingly the rules. In the top the highest values (in green in my example) and in the bottom the lowest values
PPS: you could do something similar with the help of RANK or LARGE/SMALL, depending on your data

Random select in with a bias towards certain outcomes (ie 60/40)

Lets say I have 2 lists and I would like to randomly select a winner between the lists but I would like to select the winner from list A 60% of the time and from list B 40% of the time, how can that be done in Google Sheets?
You can randomly select names from a list using this formula
INDEX(A2:A, RANDBETWEEN(1, COUNTA(A2:A)))
Without knowing some more information on your setup here is a general formula that does what you're describing:
=IF(RAND()<=0.6,INDEX(A2:A, RANDBETWEEN(1, COUNTA(A2:A))),INDEX(B2:B, RANDBETWEEN(1, COUNTA(B2:B))))
Essentially it is rolling a random number between 0 and 1. If it is equal to or less than .6 (simulating 60%, since there is a 60% chance it will be less than or equal to .6) it then selects a random name from Column A, otherwise (bottom 40%) it selects from column B.
You can also replace the "0.6" with A1 in my example to have the weight be a dynamic number. Changing A1 to 75% for example will then compare the random value against less than or equal to .75.
EDIT: Image shows the wrong condition, I was corrected in the sense you want less than or equal to .6 and not greater than, I had the weights flipped.

Is there calculation time limit in Google Sheet?

I'm using Array Formula in Google Sheet to calculate some values.
Each row has around 200 fields (from Google form).
Using the array formula, I've multiplied each column to a cell in another sheet (200 fields there).
The response has the no of units 1, 2, 3, ... and another sheet has price 5, 10, 100.
So, each unit is being calculated by its price to get a total value.
=ArrayFormula(IF(ISBLANK('Form Responses 1'!T2:T),0,'Form Responses 1'!T2:T * Data!T2))
Ok, then I've to find the total sum of all these results, for that, I'm using MMULT.
=MMULT(T2:EV100,TRANSPOSE(ARRAYFORMULA(COLUMN(T2:EV100)^0)))
Now, the actual problem is that the ArrayFormula is only showing the result (the value 0) to 104 rows only.
Is there a limitation on the amount of calculation? Or the rows will increase over time?
I've tried ArrayFormula in an isolated sheet, and it goes to the bottom.
Poor me.
I just noticed that the sheet attached with Google form had only 103 rows, that is why the arrayFormula was only showing results till 103 rows.
I added 1000 more rows and it expanded. But it is slower than before, I guess the calculations are being performed in my browser.

Nested Average(Small(offset)) in Sheets isn't producing correct result

I want to calculate the average of the smallest 20 numbers in a range (using offset), then multiply it by 0.96 using a Google sheet.
This is the formula we have:
=AVERAGE(SMALL(OFFSET(B13,2,0,20),{1;2;3;4;5;6;7;8;9;10}))*0.96
(See below for pictures)
The function should output 24, but instead it's outputting 14. I think it has something to do with the range of numbers for 'n' in the nested 'small' function, but for the life of me I can't figure out what it is. I've linked some pictures:
Thank you!
Since the data in your image only has 20 rows, i am assuming you mean to calculate average of smallest 10 numbers from the 20 rows. Try this formula
=AVERAGE(SMALL(OFFSET(B13,0,0,20,1),{1,2,3,4,5,6,7,8,9,10}))
Please note the the formula should be entered as an array i,.e. type the formula and press Ctrl + shift + enter

Use text in a cell as plus and minus

I have a sheet with multiple rows. There is a cell on each row that says "In" and "Out" in a dropdown. Basically this is plus and minus. Next to that I have a cell that that holds an amount.
So it looks like this:
Item 1, In, 10
Item 2, Out, 5
This totals a profit of 5.
How can I with this setup calculate the total profit/loss for all the cells in the sheet depending on multiple in/out rows?
An if formula will calculate the rows and a sum formula will calculate the column.
First make the numbers positive and negative values.
=IF(B2="In",C2,C2*-1)
This formula in 'D2' checks if the value of 'B2' is "In".
If yes then just adds the value of 'C2'.
If no then it multiplies the value of 'C2' by negative one.
Second step is to add up the numbers.
=SUM(D2:D3)
Cell 'D4' sums the column.

Resources