# Reporting Module Dynamic Key for Font Color

**URL:** <https://forum.inductiveautomation.com/t/reporting-module-dynamic-key-for-font-color/11720>\
**Category:** Ignition\
**Created:** [May 25, 2016, 5:48pm UTC](https://forum.inductiveautomation.com/t/reporting-module-dynamic-key-for-font-color/11720 "2016-05-25T17:48:21Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [May 25, 2016, 5:48pm UTC](https://forum.inductiveautomation.com/t/reporting-module-dynamic-key-for-font-color/11720/1 "2016-05-25T17:48:21Z")

</div>

In the new reporting module how do you use a dynamic key to change the font color?

I have tried making a key in my dataset with string of just the number. e.g. 0,255,255,255

I have also tried making a key with the expression color function color(0,255,255,255) with no luck

I have easily used dynamic keys when they are just regular data types like integers, but i am not sure how to get a data type of a color and the color will be user selectable so i cannot just make labels visible/invisible based on a boolean.

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [May 25, 2016, 6:58pm UTC](https://forum.inductiveautomation.com/t/reporting-module-dynamic-key-for-font-color/11720/2 "2016-05-25T18:58:14Z")

</div>

Here’s one way to do it:

I made a parameter of type string (sorry, I know that’s not intuitive), with a default value of `toColor("0,255,255")`

Then in my design tab, I selected the item I wanted to have a dynamic color. In the property inspector, I right-clicked on ‘fill color’ and chose ‘use dynamic data key’. Then I dragged my parameter onto the word ‘data\_key’ that replaced the previous color that had been there.

To let users select a color, override this parameter with a new one, using the `toColor("x,y,z")` format.

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [May 25, 2016, 9:02pm UTC](https://forum.inductiveautomation.com/t/reporting-module-dynamic-key-for-font-color/11720/3 "2016-05-25T21:02:02Z")

</div>

i have changed it to toColor and I also added the double quotes around the numbers, but it is still not working.

I am not using a parameter i am trying to use a key from a data source. I only want the color of the font to change on certain rows of the table.

my data source looks something like this

Label FontColor  
Tag1 toColor(“0,0,0,255”)  
Tag2 toColor(“0,0,0,255”)  
Tag3 toColor(“102,255,102,255”)

then in my table I have the Text bound to the Label key of the datasource and the Text Color bound to the FontColor key from the datasource

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [May 25, 2016, 9:10pm UTC](https://forum.inductiveautomation.com/t/reporting-module-dynamic-key-for-font-color/11720/4 "2016-05-25T21:10:45Z")

</div>

I suspect that if you want the color to change only for certain rows, you will need to use row versioning. If you’re not familiar with it, the [IU video](https://inductiveuniversity.com/video/table-row-versioning?r=/course/reporting-in-ignition) may help.

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [May 25, 2016, 9:19pm UTC](https://forum.inductiveautomation.com/t/reporting-module-dynamic-key-for-font-color/11720/5 "2016-05-25T21:19:24Z")

</div>

Row Versioning will not solve my problem because i am trying to us a color stored in the database. For row versioning to work i would have to create a version of row for ever possible color that could be stored in the database.

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [May 25, 2016, 9:28pm UTC](https://forum.inductiveautomation.com/t/reporting-module-dynamic-key-for-font-color/11720/6 "2016-05-25T21:28:30Z")

</div>

i setup a little test in my table. you can see in the picture on the left side i am displaying the key from the datasource. On the right side i am displaying the parameter that i have the toColor function as a string. it looks like for some reason the report is converting the parameter to a java color and the string that is in my datasource is being left as a string.

[attachment=0]row text color.png[/attachment]

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [May 25, 2016, 9:38pm UTC](https://forum.inductiveautomation.com/t/reporting-module-dynamic-key-for-font-color/11720/7 "2016-05-25T21:38:25Z")

</div>

String parameters are evaluated as expressions first, and if the expression fails, then as a string. Datasources are not evaluated as expressions.

---

<div class="post-metadata">

**Author:** ![shrikant](https://avatars.discourse-cdn.com/v4/letter/s/258eb7/32.png) [@shrikant](https://forum.inductiveautomation.com/u/shrikant)\
**Post date:** [May 27, 2016, 6:30am UTC](https://forum.inductiveautomation.com/t/reporting-module-dynamic-key-for-font-color/11720/8 "2016-05-27T06:30:11Z")

</div>

I am using parameter(“textColor”) to dynamically change the ‘Text Color’ on report.  
I added parameter with default value as mentioned above and dragged that parameter to ‘Text Color’. I can see color changed to green in Preview tab. But I can’t find a way to change the color dynamically on Report Viewer.

I tried following things on “textColor” parameter of the report viewer:

1. Added expression `toColor("255,0,0")` But color changed to black from default green color. Though it returned “#FF0000” in property editor.

2. Created a string tag and bound it to “textColor” parameter. Changed values of the tag to “255,0,0” (it returned “#FF0000”) and then toColor(“255,0,0”). In both cases color changed to black instead of red.

3. Added expression `"toColor({tagPath})` It also returned hex value but got same result.

Where could I be going wrong?  
Thanks.

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [May 27, 2016, 2:31pm UTC](https://forum.inductiveautomation.com/t/reporting-module-dynamic-key-for-font-color/11720/9 "2016-05-27T14:31:20Z")

</div>

I was able to do this through a little indirection.

In the report, I made two parameters. One I called “ColorString”, with a default value of “255,0,0”. The other I called “TextColor”, with a default value of “toColor({ColorString})” (except no quotes). The TextColor tag was bound to my text color in the report, and shows as red in the preview tab.

In a Vision window, I dropped a report viewer component. I made a string memory tag with a value of “0,255,0”, and dropped it onto the ColorString parameter, overriding the default value. In my report viewer, the text shows as green.

---

<div class="post-metadata">

**Author:** ![shrikant](https://avatars.discourse-cdn.com/v4/letter/s/258eb7/32.png) [@shrikant](https://forum.inductiveautomation.com/u/shrikant)\
**Post date:** [May 30, 2016, 12:19pm UTC](https://forum.inductiveautomation.com/t/reporting-module-dynamic-key-for-font-color/11720/10 "2016-05-30T12:19:06Z")

</div>

Yes. That is indeed the right way.

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![vanko25](https://avatars.discourse-cdn.com/v4/letter/v/a87d85/32.png) [@vanko25](https://forum.inductiveautomation.com/u/vanko25)\
**Post date:** [April 10, 2019, 3:08pm UTC](https://forum.inductiveautomation.com/t/reporting-module-dynamic-key-for-font-color/11720/11 "2019-04-10T15:08:03Z")

</div>

Sorry for bringing an old thread but I kind of can’t get that working.

I have the following situation - I got a report in 7.9.6 where I have a table that is being fed from a report script.

I am trying to get a table’s cell to turn red if the value in it is \> 0. So I select the cell in “Design” tab and then go to “Fill color” and select “Use dynamic data key” and finally select the parameter which I will be using as my key.

I got 2 x parameters as above. One called “ **accidentColor** ” of type string and it has a value:

`“255,255,255” `  
Then have another parameter called “ **accidentFlag** ” of type string with the following expression:

`toColor({accidentColor})`

Up to this point is all good. But I can’t make my script to do anything. It seems to compile okay but it won’t turn the cell red.

`if accidentSum > 0:
data[‘accidentColor’] = “255,0,0”
`  
_“”“I can’t the indentation correct in here but it is properly indented”""""_

I have created some new text boxes and assigned in the Design tab and binded both my parameters to them and this is what I get:

![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/a/aae3938ee591c39b6a99a4e43b7f3291d63f71e0.png)

So it seems that the **If statement** is executed, the value **“255,0,0”** is transferred to **accidentColor** but somehow it is not used in **accidentFlag**. As the bottom line is still showing the default color.

I made sure that the positions of the 2 parameters is appropriate but I think the order of execution of the parameters and the script is somehow messing it up for me.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/6/64139017def6df001c97384e59106baa32615b29.png)

Any help is appreciated!
