# Change the font color of perspective table on condition

**URL:** <https://forum.inductiveautomation.com/t/change-the-font-color-of-perspective-table-on-condition/71879>\
**Category:** General Discussion\
**Tags:** vision, perspective\
**Created:** [March 31, 2023, 6:25am UTC](https://forum.inductiveautomation.com/t/change-the-font-color-of-perspective-table-on-condition/71879 "2023-03-31T06:25:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [March 31, 2023, 6:25am UTC](https://forum.inductiveautomation.com/t/change-the-font-color-of-perspective-table-on-condition/71879/1 "2023-03-31T06:25:04Z")

</div>

Hi,

I want to change the color of font in the perspective table on giving condition.  
I tried all steps which is in forum links related to this topic, but not succeeded.  
Example:

if (value of 1st column is greater than 2nd column)  
change the font color of 2nd column to green  
else remains same

as in vision I have done but not getting in perspective.

please guide

Thank you

---

<div class="post-metadata">

**Author:** ![jonathan.taylor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jonathan.taylor/32/4048_2.png) [@jonathan.taylor](https://forum.inductiveautomation.com/u/jonathan.taylor)\
**Post date:** [March 31, 2023, 7:55am UTC](https://forum.inductiveautomation.com/t/change-the-font-color-of-perspective-table-on-condition/71879/2 "2023-03-31T07:55:46Z")

</div>

There are some examples to help you style values in the table here:

[https://docs.inductiveautomation.com/display/DOC81/Perspective+-+Table#PerspectiveTable-Examples](https://docs.inductiveautomation.com/display/DOC81/Perspective+-+Table#PerspectiveTable-Examples)

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [March 31, 2023, 9:20am UTC](https://forum.inductiveautomation.com/t/change-the-font-color-of-perspective-table-on-condition/71879/3 "2023-03-31T09:20:29Z")

</div>

yes I tried, I got it for specific row, given hardcoded values in the script.  
But I want to change only one column font color by comparing the values with other column.  
Then we should read the row values of one column and compare other column right.

how can I apply this in script.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/8/c8f969989033ede942e4ef53fe1faec369a0d46e.png)

---

<div class="post-metadata">

**Author:** ![amy.sudibyo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amy.sudibyo/32/38659_2.png) [@amy.sudibyo](https://forum.inductiveautomation.com/u/amy.sudibyo)\
**Post date:** [April 6, 2023, 2:01am UTC](https://forum.inductiveautomation.com/t/change-the-font-color-of-perspective-table-on-condition/71879/5 "2023-04-06T02:01:29Z")

</div>

Something like the below should work for your script transform. I've assumed that the data going into your table is a dataset.

```auto
	output_json = []
	style_red = {"color": "#FF0000"}
	style_black = {"color": "000000"}
	 
	for row in range(value.getRowCount()):
		row_object = {}
		row_value = {}

		for col in range(value.getColumnCount()):   
	        	        
			if value.getColumnName(col) == "Actual":
				if value.getValueAt(row, "Actual") < value.getValueAt(row,"Target"):
					cell_style = style_red
				else:
					cell_style = style_black

			else : 
				cell_style = style_black                     
		
			row_value[value.getColumnName(col)] = {'value':value.getValueAt(row, col),'style':cell_style}
		row_object['value'] = row_value
		output_json.append(row_object)
		
	return output_json

```

---

<div class="post-metadata">

**Author:** ![amy.sudibyo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amy.sudibyo/32/38659_2.png) [@amy.sudibyo](https://forum.inductiveautomation.com/u/amy.sudibyo)\
**Post date:** [April 6, 2023, 5:13am UTC](https://forum.inductiveautomation.com/t/change-the-font-color-of-perspective-table-on-condition/71879/7 "2023-04-06T05:13:40Z")

</div>

Sorry I realised I have a typo in my transform in the style\_black colour, obviously a hex colour code needs to start with a #.

The column positions in the output json don't really matter, you can specify column order when you set up the column configuration on your table.

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [April 8, 2023, 10:27am UTC](https://forum.inductiveautomation.com/t/change-the-font-color-of-perspective-table-on-condition/71879/8 "2023-04-08T10:27:02Z")

</div>

Thank you so much. I got it exactly.
