Conditional Formatting Based on Multiple Rules - google-sheets

I'm trying to create a multi rule custom formula for conditional formatting purposes in Google Sheets.
Here is what I want to achieve -
If Deal Size is Small, the deal length cell should be highlighted a specific color based on the criteria -
0-35 Green
35-40 Yellow
40+ Red
If Deal Size is Large, the deal length cell should be highlighted a specific color based on the criteria -
0-45 Green
45-55 Yellow
55+ Red
Here is some sample data -
Date Deal Started
Date Deal Ended
Deal Length
Deal Size
1/13/2023
1/25/2023
12
Small
12/8/2022
1/17/2023
40
Large
11/8/2022
1/9/2023
62
Small
10/7/2022
1/31/2023
116
Large
12/12/2022
1/30/2023
49
Large
I've read some blogs online but haven’t found a solution for what I want to achieve.

0-35 for green and 35-40 for yellow. So what color if exactly 35?
Use 3 custom formulas for conditional formatting. Move = signs where needed. Range in example C2:C7
Green:
=OR(AND(D2="Small",C2>0,C2<35),AND(D2="Large",C2>0,C2<45))
Yellow:
=OR(AND(D2="Small",C2>=35,C2<40),AND(D2="Large",C2>=45,C2<55))
Red:
=OR(AND(D2="Small",C2>=40),AND(D2="Large",C2>=55))
Result:

or you can do it like this too:
green:
=((D2="Small")*(C2>0)*(C2<35))+((D2="Large")*(C2>0)*(C2<45))
yellow:
=((D2="Small")*(C2>=35)*(C2<40))+((D2="Large")*(C2>=45)*(C2<55))
red:
=((D2="Small")*(C2>=40))+((D2="Large")*(C2>=55))

Related

Color contrast formula ? (ImageMagick)

I reduced an image to 12 colors, annotated with some text (here it's color saturation, sorted) :
The text color is %[pixel:p{10,10}*2] (background *2) (I made a little script that I can share if you're interested).
As you can see, text is not very readable (contrast) in all cases (colors). Is there a smarter formula than a simple linear scaling to make text pop in all/most cases ?
As per Fred's suggestion, using luminosity is much better. Using black & white text depending on luminosity > 56 or not :
And for a not colorful image :
The text represents L component of HSL value. Notice the change from black to white when value crosses 56.

How to increase contrast between colors generated from image?

Some details:
I'm making a small prototype in Framer, some kind a wallpaper app. I use vibrant.js to automatically pick colors from the images to add a bit of a tint to my interface. I use two vibrant color profiles: "DarkMuted" - for the backgrounds and "Vibrant" - for active controls / accents etc.
Unfortunately, color combintation looks dull and desaturated sometimes, active elements don't stand out as much as I want it.
So my first decision was to
Blindly edit colors.
I convert them to hsl and explicitly set s and l values.
s: .2, l: .2 # DarkMuted
s: .6, l: .8 # Vibrant
This creates enough contrast between the two, but also has a drawback: sometimes colors look a bit oversaturated and distorted (compared to the input).
By this link you can find pairs of screenshots to show you the difference between "original" color pair returned by "vibrant.js" and colors with adjusted s and l values.
I've already asked on another forum if it's possible to apply automated adjustments to the color, to normalize percieved bias for some color ranges. The answer was "almost impossible".
I would say that subjectively acceptable color rate is ~ 65% but the result is too unpredictable. Since it's an automatic solution I can't rely on that too much.
So I decided to approach it another way:
Generate a bunch of colors and filter one
The problem here is:
I've not found how to generate more than one color per profile with vibrant.js
Also, I've tried the color-thief.js library to generate a palette of dominant colors and then filter, what I call, a "vibrant" color.
# Threshold values I used
thr = {minL: .4, maxL: .8, minS: .6, maxS: .8}
But here the another problem occurs - not every image has a set of colors that fall under my threshold. Some images have a pastel gamma or b/w and don't return anything.
So,
Can I overcome the vibrant.js limitation of 1 color per profile to have a bunch of "Vibrant" colors and then pick one that suits my requirements?
Or, maybe, there is another / better solution of doing it?
There is a specification about minimum contrast between colors (WCAG) you can find it here. So a possible strategie would be extracting the colors with vibrant.js and after that you could check contrast with a function. You can find a guide to build a function to check color constrast here. The last step probably would be generate colors variations with good contrast based on the results from the color contrast function. You can generate variations using this lib.

UIView background color set is not what appears

I created a UIView with a set background color. Lets say RGB value 185, 45, 42. For some reason, when I take a screenshot of this view, it is not that color. It is a little bit darker. Is there a reason why UIView would do this?
The UIView background color is set in interface builder like this:
When I run it on the simulator and take a screenshot and use the eye drop tool to determine the color, the numbers that show up are a little bit darker than what I entered. Same with a button.
I have other screens with the same red color and the screenshot I take of those, the red actually comes out correctly. I've been trying to determine what the difference is between those screens, but so far have not seen any. So I was just wondering if anyone would have any knowledge of anything that "could" case such a color change.
A common mistake when setting a color numerically in Interface Builder is to neglect the color space:
Different color spaces will give different colors (visually) for the same RGB values.
When you set RGB color, you should notice that all the three color values range from 0 to 1, so give them a value greater than 1 would never work. Try this:
RGB(185 / 255.0, 45 / 255.0, 42 / 255.0)

How to do greater than/less than conditional formatting?

I am having issues when trying to use a greater than and less than conditional formatting. I would like to be able to change the color of a cell (E62) to green if it is less than another cell (E64) and if that is false I want to change it (E62) to red if it is greater than the the other cell (E64).
Hopefully that was easy to understand.
Try making two rules:
LessThan =E64, BackgroundColor green, Range E62
GreaterThan =E64, BackgroundColor red, Range E62

Google sheets custom number format, color specification

I have a customized number format for my percentages. Here is the code:
[Green]#,##0.0%;[Red](#,##0.0%)
Output preview:
Positive: 123,456.0% # Green
Negative: (123,456.0%) # Red
I want the Green to be darker, I've tried [Dark Green], [Dark_Green], [dark green 1] (from Google's fill color drop down), and even hex codes [#00ff00] for Green, none of them work.
Try this:
[Color10]#,##0.0%;[Red](#,##0.0%)
For more information goto https://support.google.com/docs/answer/56470?p=drive_custom_numbers&rd=1

Resources