cancel
Showing results for 
Search instead for 
Did you mean: 

Embedded Lights

Former Member
0 Kudos

In the use of embedded lights, the value inside the lights is the value returned from the sql query. I want to hard code a value of “C” inside the light but drive the color of the light off the results of the sql query. Is there a way to do this?

Accepted Solutions (0)

Answers (1)

Answers (1)

jcgood25
Active Contributor
0 Kudos

B.J.,

I would use a CASE statement like this:

SELECT (CASE WHEN MyColumn < 50 THEN '<R>' ELSE '<G>' END) AS MyStatus FROM MyTable

Then in the Display Template use String match mode to color context the MyStatus column for Green <G> and Red <R>

Regards,

Jeremy Good

Former Member
0 Kudos

If I did it that way, the letter G or R would show up in the light. I want green for G and R for red, but inside the light I want the letter C.

jcgood25
Active Contributor
0 Kudos

The Embedded Lights mode shows the single letter that falls between the < > symbols, and was originally intended for addressing the prevalant red/green color-blind concerns (as evidenced in my example). It also color contexts based upon this, so using this mode you can't have the letter C jammed into the lights unless you color it accordingly.

I haven't tried this before, but maybe use upper case <C> for Red and lower case <c> for Green?

Regards,

Jeremy

Former Member
0 Kudos

Dear Jeremy,

I am trying to do the same as you have in your examples. The following select statement works for MySQL DB,

SELECT devicename, data01, oname, CASE data01 WHEN 'off' THEN '<R>' ELSE '<G>' END FROM events ORDER BY timestamp01 DESC LIMIT 15;

I tried in the fixed query on the BLS and it gives me the correct output with <G> values substituted in the column.

In the color context, substituting the <G> with a color produces a traffic light with the color of choice.

Then I tried

SELECT devicename, data01, oname, CASE data01 WHEN 'off' THEN '<R>' WHEN 'No_WP' THEN '<Z>' ELSE '<G>' END FROM events ORDER BY timestamp01 DESC LIMIT 15;

does give a query result. Then I used the Color Context and added a row with a color of my choice and under the status column I had <Z> matched for this new color.. viola..it works !

Cheers

Domnic

Edited by: domnic savio on Apr 20, 2008 1:10 AM

Edited by: domnic savio on Apr 20, 2008 1:17 AM

jcgood25
Active Contributor
0 Kudos

Domnic - glad you got the extra functionality working, but keep in mind that you should always alias your case statement into a named column similar to my earlier post.

Regards,

Jeremy

Former Member
0 Kudos

Yes you are right Jeremy. I did realize that. I alias it now. Thanks again

cheers

Domnic