# Changing colour of row based off value in cell in perspective table

**URL:** <https://forum.inductiveautomation.com/t/changing-colour-of-row-based-off-value-in-cell-in-perspective-table/43587>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [February 18, 2021, 7:51pm UTC](https://forum.inductiveautomation.com/t/changing-colour-of-row-based-off-value-in-cell-in-perspective-table/43587 "2021-02-18T19:51:52Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [February 22, 2021, 4:06pm UTC](https://forum.inductiveautomation.com/t/changing-colour-of-row-based-off-value-in-cell-in-perspective-table/43587/17 "2021-02-22T16:06:10Z")

</div>

It sounds like you’re not making the row data homogeneous.

Early examples in this thread suggested you only need modify the piece of data you wanted to color. Later examples moved toward setting the background color of the row. based on some condition.

To use the binding/transform combo I supplied, each row will need to have the same structure whether it meets the condition or not. so you’ll want to adjust the logic so that each row has the background color set, but the color is different based on your condition:

```auto
	pydset = system.dataset.toPyDataSet(value)
    backgroundColor = '#00FF00' # if condition met
	returned_rows = []
    default_background_color = ''
	for row in pydset:
		row_dict = {}
		if int(row['population']) < 3000000:
			row_dict['population'] = {'value': row['population'], 'style': {'backgroundColor': backgroundColor}}
		    row_dict['country'] = {'value': row['country'], 'style': {'backgroundColor': backgroundColor}}
		    row_dict['city'] = {'value': row['city'], 'style': {'backgroundColor': backgroundColor}}
        else:
            row_dict['population'] = {'value': row['population'], 'style': {'backgroundColor': default_background_color}}
            row_dict['country'] = {'value': row['country'], 'style': {'backgroundColor': default_background_color}}
            row_dict['city'] = {'value': row['city'], 'style': {'backgroundColor': default_background_color}}
		returned_rows.append(row_dict)
	return returned_rows

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/changing-colour-of-row-based-off-value-in-cell-in-perspective-table/43587)._
