Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Changing the Color of a Cell Values in Table Box

What is the way to change the color (text and background) of a Cell dynamically in Table box?

Example:

Color FieldAttribute 1Attribute 2
GreenAABC
BlueBDEF
YellowCGHI

I want to color the Color Field based on the values it contains.

Eg:

If( Color Field = 'Green', Green(), If( Color Field = 'Blue', Blue() )) etc.,

Note: I don't want to use Straight Table - because my Table contains close to 80 Attributes/Dimensions.

Things I tried:

1. Enabled Grid View.

2. Right click on one of the cells in Color Field -> Custom Format Cell

3. In the Background Color and Font Color, gave the conditions like mentioned in the Example.

4. Apply this to 'Current Dimensions'

5. Nothing Changes.

6. If I select Green/Blue/Yellow, the color changes. That is not what I want.

Is there a way to give in the IF Condition that will take the field value and check in real time and then does the coloring part?

5 Replies
MK9885
Master II
Master II

Maybe try

if(GetFieldSelections([Color Field])='Green', Green(),If( GetFieldSelections( [Color Field]) = 'Blue', Blue(),

If( GetFieldSelections( [Color Field]) = 'Yellow', Yellow())))

In your Text Color Expression?

the color would only change for Green Blue and Yellow if the values are selected in filter or it would stay as default.

Anonymous
Not applicable
Author

Hi Aehman,

Thanks for your response. That is exactly what I don't want it to happen.

GetFieldSelection() / Actual Field names, doesn't matter here. Both give me the same result - which is the colors are applied based on some selection of the color.

Instead, I want the Colors to be applied based on the Field Values itself without users selecting a particular color value here.

sergio0592
Specialist III
Specialist III

Hi, try with a table color load :

Colors:
LOAD *
,rgb(R,G,B) as Color
INLINE [
Color_Field,R,G,B
Green,0,205,0
Blue,0,0,205
Yellow,238,201,0
];


Once you've loaded the table, go into Background color and write : Only({<Color_Field=>} Color)

to avoid color change on user selection on color field.

effinty2112
Master
Master

Hi Koushik,

Don't use a table box, DO use a straight table then you will be able to control the colours of individual cells by expanding the dimension's icon in the used dimensions list in the dimensions tab .


Don't add any expressions, in the Presentations tab de-select Suppress Zero Values.

Regards

Andrew

Or
MVP
MVP

As far as I know, the custom format option is not aware of the underlying object. As such, you can't set a dynamic row color using this option.

You can achieve basically the same result by adding all of your fields as dimensions, adding one expression, and hiding that expression. You can then use a formula to set the color. If your fields contain actual legal color names, you can actually use a nifty script trick:

Load *, Evaluate(Color & '()') as Color2;

LOAD * INLINE [

    Color, Text

    Green, ABC

    Blue, DEF

    Yellow, GHI

];

You can then use the Color2 field in your dimension / expression background or text color, as is, to set the color.