Highlight cell in the table

Hello, I need help with the table below.

I would like to highlight the cell background RFT value to the background RED if the value is less than the Target and Green if it is more than the Target.
In this picture the value 49 in Hour 1 I would like the background GREEN but if the value 49 was 47 or less I would like RED.

All those values in the table came from SQL and it is binding a Query.

Thanks

You will have to convert your dataset to an object with a transform script and do some tests with the values.
A script like that could do the trick :

	data = []
	style = {"backgroundColor": "", "fontStyle": "normal"}
	style_green = {"backgroundColor": "#00FF00", "fontStyle": "normal"}
	style_red = {"backgroundColor": "#FF0000", "fontStyle": "normal"}
	for ligne in range(value.getRowCount()):
		data_ligne = {}
		for col in value.getColumnNames():
			data_ligne[col] = value.getValueAt(ligne ,col)
		if ligne == 2 and value.getValueAt(ligne ,col) < value.getValueAt(ligne-1 ,col):
			data.append({"value":data_ligne, "style":style_red})
		elif ligne == 2 and value.getValueAt(ligne ,col) > value.getValueAt(ligne-1 ,col):
			data.append({"value":data_ligne, "style":style_green})
		else:
			data.append({"value":data_ligne, "style":style})
	return data
1 Like