Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
What is the way to change the color (text and background) of a Cell dynamically in Table box?
Example:
Color Field | Attribute 1 | Attribute 2 |
---|---|---|
Green | A | ABC |
Blue | B | DEF |
Yellow | C | GHI |
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?
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.
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.
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.
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
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.