Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Setting a traffic light based on text in a record

Hello All,

I am trying to set a traffic light based on a value of a particular field. The field is a status field. It has 3 possible values. I would like the traffic light displayed green, yellow or red depending on the value of the field (text value). I have searched the forums and tried over and over to get this to work.

Can someone please explain something from begining to end. I'm assuming I must use a table chart. I tried this and couldn't get it to work. It's basically a report that's displayed and I want the last column to display a traffic light based on one of the fields value (remember it's a text value like ONTIME, LATE and NOTDELIVERED). ONTIME = green, LATE = red and NOTDELIVERED = yellow (all traffic lights.

Please help!

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

See attached example. Basically, you put in the 1, 2 and 3 as the segment boundaries, and set the color for each segment appropriately.

View solution in original post

5 Replies
Not applicable
Author

You can do this several ways including changing texts and background colours but I think what you are after are the bundled images that mimic traffic lights.

Yes you need a chart of some sort (pivot or table) then create an expression like this :

if (fieldname='good', 'qmem://<bundled>/BuiltIn/led_g.png', if (fieldname='notsogood', 'qmem://<bundled>/BuiltIn/led_o.png', 'qmem://<bundled>/BuiltIn/led_o.png'))

This represents a compound conditional statement like this:

if fieldname = 'good' then

show green traffic light

else if fieldname = 'notsogood'

show orange traffic light

else

show red traffic light

Remember to change the 'display options' under the expressions tab on the'chart properties' to representation = 'image'.

Hope that helps,

Gordon

johnw
Champion III
Champion III

I'd probably make your status field a dual() field:

dual(Status,match(Status,'ONTIME','NOTDELIVERED','LATE')) as Status

While you will still normally see Status as text, it then also has an underlying value of 1, 2 or 3. That allows you to set up a traffic light for the field just like you would for any other numeric field.

Not applicable
Author

Hi John, I used the function you mentioned and for the first time got past 'Error in expression' message. Now, where do I put the Ontime = 1 and green traffic light, notdelivered = 2 and yellow traffic light and late= 3 red traffic light?

I put in Representaiton - Traffic Light Guage. Then go into Guage settings and don't know what to put here.

Can you please help? I've been on this all day.

Thank you!

johnw
Champion III
Champion III

See attached example. Basically, you put in the 1, 2 and 3 as the segment boundaries, and set the color for each segment appropriately.

Not applicable
Author

Thanks John. That's just what I needed. Regards.