Hi,
I want to make a list of products ('name') that have different deadlines ('tr_datetime_finished').
I want the background color to change according to the time to the deadline. something like 5 t deadline is red, 10 yellow, and rest green
I am doing something wrong when using the advanced formatting only for two colors:
Can someone give me a hand?
var endDate=§datapoint['tr_datetime_finished']
var startDate= Today()
var timetoFinish = DateDiff(endDate, StartDate, 'days')
var color = iff(timetoFinish < 5, 'color1', 'color2')
return {
backgroundColor: color,
}
Cheers
Pedro
That should work if you're using the proper color codes. This code show an example of changing the background color using a When function and the text color using an Iif function
var theDate = Text($datapoint.FishDate, 'MMMM D, Y');
var bgColor = When(theDate == 'June 6, 2023', '#FF0000',
theDate == 'June 7, 2023', '#FFFF00',
theDate == '', '#ffffff',
'#e2e2e2');
var textColor = Iif(theDate == 'June 6, 2023', '#ffffff', '#000000');
return {
textColor: textColor,
backgroundColor: bgColor
}