I'm attempting to vary the color of a specific word depending on what is added (critical, high, medium, or low), but the only color showing up is the yellow (#ecf229) from the else statement. Does anyone know what I'm getting wrong with the if/else statement? I believe that's where the issue might be but I'm not certain.
Here's the expression I've added to the advanced formatting for the list.
var lOI = ''
if ($datapoint.level_of_impact=="Critical"){lOI= '#e01d1d'}
else if($datapoint.level_of_impact=="High"){lOI= '#ff7300'}
else if($datapoint.level_of_impact=="Medium"){lOI= '#73b2ff'}
else {lOI= '#ecf229'}return {
textColor: '',
backgroundColor: '',
separatorColor:'',
selectionColor: '',
selectionTextColor: '',
attributes: {
attribute1: lOI
// attribute2: ''
}
}
Here's what I have in the source for the line item template, which seems to be working correctly as it is adding a color - just not always the correct one.
<p><strong><span style="color:{expression/attribute1}">{level_of_impact}</span></strong></p>
Solved! Go to Solution.
Is that field in a domain? If so, you'll need to use the domain code or the DomainName function
var level = DomainName($datapoint, "level_of_impact");
var lOI = When(
level == "Critical", "#e01d1d",
level == "High", "#ff7300",
level == "Medium", "#73b2ff",
"#ecf229"
);
Is that field in a domain? If so, you'll need to use the domain code or the DomainName function
var level = DomainName($datapoint, "level_of_impact");
var lOI = When(
level == "Critical", "#e01d1d",
level == "High", "#ff7300",
level == "Medium", "#73b2ff",
"#ecf229"
);
Perfect! That's the mistake I was making. Thank you!