Most Efficient?

I was wondering, i have been trying various things and I would like to know if this is the most efficient way of doing a certain task.

The task is I have two SQL tags for each of the containers on a page within PMI. Depending on the state of these tags would determine the color of the container. So if you think of it in boolean there is 4 possible combinations, 00, 01, 10 and 11. What I have done is within each container I have taken and made a customized item. The item is set as an Integer. Then within the expression for this customized item I have the following:

switch(binenc(toint(tag("[]enable/enable1"),toint(tag("[]active/active1")),0,1,2,3,0,1,2,1,0)

The color of the container is then set 0 is red, 1 is green and 2 is yellow.

It seems to work just fine but was wondering if this is the best solution.

Thanks and have a great day.

Yes, this is a great approach. The only (minor) difference is that I probably would have just used the expression languages native tag reference syntax rather than the tag() function, like this:

(also note how you can use spacing to make expressions clearer)

switch( binenc(toint({[]enable/enable1}),toint({[]active/active1})), 0,1,2,3, 0,1,2,1, 0 )

But you don’t need to bother changing what you have - it’ll work very well.

Also, if those tags are any kind of number or boolean, you can drop the “toInt” casting functions.