Conditional Formatting Google Sheets Query - google-sheets

I am trying to write a query in google sheets that will affect conditional formatting. Below is my example dataset
A B C D E F G H I J
1 Signficance 1 0.5 -0.9 0.8 0.7 0.6 0.95 0.94 0.8
2 Number of Events 13 13 13 13 13 13 10 8 13
3 Lift 9 4 12 9 5 4 10 12 10
I want to fill in the following colors in the lift row with these rules:
If Signficance >= 0.9, then highlight corresponding Lift cell with Green
If Signficance >= 0.8 and Signficance < 0.9, then highlight corresponding Lift cell with Blue
If Signficance <= -0.9, then highlight corresponding Lift cell with Red
Any other significance, highlight corresponding Lift cell with Gray
The desired result will highlight the following cells as:
B3 = Green
C3 = Gray
D3 = Red
E3 = Blue
F3 = Gray
G3 = Gray
H3 = Green
I3 = Green
J3 = Blue
Here is my attempt which is time consuming for every cell:

4 rules:
Apply to Range for each: B3:3
Rule 1, Custom:
=B1<=-0.9
Red
Rule 2,Custom:
=B1>=0.9
Green
Rule 3,Custom:
=B1>=0.8
Blue
Rule 4, "Cell is not Empty"
Grey
It's important that the rules are in that order. As the order in which the rules are listed creates priority among the rules and allows you to keep them simpler.

Select the entire Row 3 by clicking on the 3 to the outside left of the grid.
Then you will apply four custom CF rules (i.e., each rule will have "Custom formula is..." selected under Format rules / Format cells if...). There are other ways to set up these rules, but I'm choosing this method for ease of explanation and process.
Apply the following CF rules in order:
1st / green rule
Enter the following formula in the field below "Custom formula is...":
=AND(ISNUMBER(A3),A1>=0.9)
Select a green background color and click "Done."
2nd / blue rule
Enter the following formula in the field below "Custom formula is...":
=AND(ISNUMBER(A3),A1>=0.8)
Select a blue background color and click "Done."
3rd / red rule
Enter the following formula in the field below "Custom formula is...":
=AND(ISNUMBER(A1),A1<=-0.9)
Select a red background color and click "Done."
4th / gray rule
Enter the following formula in the field below "Custom formula is...":
=ISNUMBER(A3)
Select a gray background color and click "Done."
It's important that the rules be in the above order, with green at the top and gray at the bottom of the CF rules stack.

Related

Google Sheets conditional formating based on % of another value

I have the following data:
What I want to do is based on the values in column B (Planned) change the color of the background of cells in column C (Done). Until Matt reaches 50% of his 100 hours I want the background to be green, when he reaches 75% yellow, and 100% red. Same for other people If Jasmine 50% of 40 -> green and so on.
Those numbers in the planned column will be typed in manually.
Is there a way to achieve that?
green:
=C5/B5%<=50
yellow:
=C5/B5%<=75
red:
=C5/B5%=100
This needs 3 conditional format rules in the following order (the order is important):
Apply all rules to the range C5:C
Custom formula is =C5/B5 <= 0.5, set background colour green
Custom formula is =C5/B5 <= 0.75, set background colour yellow
Custom formula is =C5/B5 <= 1, set background colour red

How to change the cell colors of a column according to the cell's value distance to the column average?

I am building a spreadsheet with a column with values that I would like to create a more visual way to identify discrepancies. So I would like to change the colors of the cells in a column according to the distance from the cell value to the column average.
For example, in this column I have the following values:
8
14
1
12
6
19
Their average is 10, I would like the cells to automatically have the colors:
8 (lighter red)
14 (green)
1 (darker red)
12 (lighter green)
6 (red)
19 (darker green)
I thought about averaging this column in a cell and putting color conditional formatting for values larger and smaller than this column mean. But in this case, my cells would have only two colors: red for below-average values and green for above-average values. Is there any way to change the color of these columns according to the discrepancy with the average of that column? Thanks in advance.
in Google Sheets it's like this:
You can use Color Scales in Conditional Formatting for this: Select a New Rule With your Desired colors for Minimum & Maximum Value
Result:
Same Goes if you are using Google Sheets. Goto Format>Conditional Formatting> Color Scales
Assuming you have excel 2016 or newer, simply highlight the data you want to have included, and then click Conditional Formatting (from the "Home" ribbon), then click "Color Scales" and pick the desired one.
After setting the color scale, you can then modify it by selecting the same data, and then clicking "modify rules". What you've stated is a 2-color scale, and that is one of the options you can choose if you go back and edit the rules.

Google Spreadsheet conditional formatting for 2 columns

I am trying to have custom formula for conditional formatting, but it doesnt seem to work with the 2 conditions...:
Columns TS Time
Row1 Y 80
Row2 N 85
Row3 Y 60
Row4 N 4
Column 'Time' --> Should be
Red if Time >= 80 and TS = 'N'
Orange if Time >= 80 and TS = 'Y'
Yellow if Time< 80 and Time > 24 --> This works
Green if Time <= 24 --> This works
You can do this with the conditional formatting, set the range to be applied to for the column you want highlighted, choose custom formula and add each one of these as it's own rule:
For orange:
=if(and(C:C>=80,B:B=""Y""),true,false)
and for red:
=if(and(C:C>=80,B:B=""N""),true,false)

Highlight Entire Row Based on Two Variables

I would like the row of Sheet 1 to be highlighted Red if Column K (Sheet 1) matches Column K (Sheet 2) and Column D (Sheet 2) says "Apple". I will have three variables in Column D to trigger three colors. For example, Apple = Red, Banana = Yellow, and Lime = Green.
What would the conditional formatting be if I wanted to highlight the entire row based on two variables?
Please try selecting the columns to be formatted (say A:Z) Sheet 1, Format > Conditional formatting..., Custom formula is:
=and(match($K1,indirect("Sheet 2!$K:$K"),0)>0,indirect("Sheet 2!$D:$D")="Apple")
with red formatting of your choice. Range: should show A:Z (extend as required).
Then + Add another rule as above for each of "Banana" and "Lime" in place of "Apple" with yellow and green to suit.

Conditional formatting based on another cell's value

I'm using Google Sheets for a daily dashboard. What I need is to change the background color of cell B5 based on the value of another cell - C5. If C5 is greater than 80% then the background color is green but if it's below, it will be amber/red.
Is this available with a Google Sheets function or do I need to insert a script?
Note: when it says "B5" in the explanation below, it actually means "B{current_row}", so for C5 it's B5, for C6 it's B6 and so on. Unless you specify $B$5 - then you refer to one specific cell.
This is supported in Google Sheets as of 2015:
https://support.google.com/drive/answer/78413#formulas
In your case, you will need to set conditional formatting on B5.
Use the "Custom formula is" option and set it to =B5>0.8*C5.
set the "Range" option to B5.
set the desired color
You can repeat this process to add more colors for the background or text or a color scale.
Even better, make a single rule apply to all rows by using ranges in "Range". Example assuming the first row is a header:
On B2 conditional formatting, set the "Custom formula is" to =B2>0.8*C2.
set the "Range" option to B2:B.
set the desired color
Will be like the previous example but works on all rows, not just row 5.
Ranges can also be used in the "Custom formula is" so you can color an entire row based on their column values.
One more example:
If you have Column from A to D, and need to highlight the whole line (e.g. from A to D) if B is "Complete", then you can do it following:
"Custom formula is": =$B:$B="Completed"
Background Color: red
Range: A:D
Of course, you can change Range to A:T if you have more columns.
If B contains "Complete", use search as following:
"Custom formula is": =search("Completed",$B:$B)
Background Color: red
Range: A:D
I've used an interesting conditional formatting in a recent file of mine and thought it would be useful to others too.
So this answer is meant for completeness to the previous ones.
It should demonstrate what this amazing feature is capable of, and especially how the $ thing works.
Example table
The color from D to G depend on the values in columns A, B and C. But the formula needs to check values that are fixed horizontally (user, start, end), and values that are fixed vertically (dates in row 1). That's where the dollar sign gets useful.
Solution
There are 2 users in the table, each with a defined color, respectively foo (blue) and bar (yellow).
We have to use the following conditional formatting rules, and apply both of them on the same range (D2:G3):
=AND($A2="foo", D$1>=$B2, D$1<=$C2)
=AND($A2="bar", D$1>=$B2, D$1<=$C2)
In English, the condition means:
User is name, and date of current cell is after start and before end
Notice how the only thing that changes between the 2 formulas, is the name of the user. This makes it really easy to reuse with many other users!
Explanations
Important: Variable rows and columns are relative to the start of the range. But fixed values are not affected.
It is easy to get confused with relative positions. In this example, if we had used the range D1:G3 instead of D2:G3, the color formatting would be shifted 1 row up.
To avoid that, remember that the value for variable rows and columns should correspond to the start of the containing range.
In this example, the range that contains colors is D2:G3, so the start is D2.
User, start, and end vary with rows
-> Fixed columns A B C, variable rows starting at 2: $A2, $B2, $C2
Dates vary with columns
-> Variable columns starting at D, fixed row 1: D$1
Basically all you need to do is add $ as prefix at column letter and row number. Please see image below
change the background color of cell B5 based on the value of another cell - C5. If C5 is greater than 80% then the background color is green but if it's below, it will be amber/red.
There is no mention that B5 contains any value so assuming 80% is .8 formatted as percentage without decimals and blank counts as "below":
Select B5, colour "amber/red" with standard fill then Format - Conditional formatting..., Custom formula is and:
=C5>0.8
with green fill and Done.
I'm disappointed at how long it took to work this out.
I want to see which values in my range are outside standard deviation.
Add the standard deviation calc to a cell somewhere =STDEV(L3:L32)*2
Select the range to be highlighted, right click, conditional formatting
Pick Format Cells if Greater than
In the Value or Formula box type =$L$32 (whatever cell your stdev is in)
I couldn't work out how to put the STDEv inline. I tried many things with unexpected results.
I just want to explain it in a another way. In "custom formula" conditional formatting you have two important fields:
Custom formula
Apply to
Let's say, you have a simple sheet with test percentages of students, where you want to color Student Ids(Column B) where their score(Column C) > 80%:
Row
B(Student ID)
C(Score)
1
48189
98%
2
9823
6%
3
17570
40%
4
60968
23%
5
69936
7%
6
8276
59%
7
15682
96%
8
95977
31%
To design a custom formula, you only need to design a formula for the top left of the range, you want to color. In this case, that would be B1.
The formula should return
TRUE, if it should be colored and
FALSE, if it shouldn't be colored
For B1, the formula would then be:
=C1>80%
Now imagine that you put that formula in B1(Or just use a another range to test it). It would be like:
Row
B
C
1
TRUE
2
3
4
5
6
7
8
Now imagine dragging the formula(or autofill) up to B8 from B1. This is how it would look like
Row
B
C
1
TRUE
2
FALSE
3
FALSE
4
FALSE
5
FALSE
6
FALSE
7
TRUE
8
FALSE
This translates directly to color B1 and B7. Now the interesting thing is All of this is autocalculated using the given formula for B1 and the Apply to range. If you fill:
Custom formula: =C1>80% and
Apply to: B1:B8
you're saying
Fill the custom formula =C1>80%
in the top left cell of the provided range B1:B8,i.e., B1 and
drag/autofill the formula to the whole range B1:B8 and
Color the cells, where the formula outputs TRUE
If you want to color both student IDs and score, you would use
Custom formula:
=$C1>80%
Apply to:
B1:C8
The $ in the $C1 says not to change C, when autofilling the range. In the imaginary table(I suggest you to output the table somewhere). This would look like:
Row
B
C
1
TRUE
TRUE
2
FALSE
FALSE
3
FALSE
FALSE
4
FALSE
FALSE
5
FALSE
FALSE
6
FALSE
FALSE
7
TRUE
TRUE
8
FALSE
FALSE
In this way, you can color any cell anywhere based on any other cell.

Resources