Switch in expression binding

I want to show text in a label depending on the tag value.
For eg
1--A
2--B
3--C
4--D
5--E

How do i bind the expression if my tag name is Tag1?
Is it possible by using Switch in expression binding?

Use a tag binding and a map transform.

Please elaborate.

I'm not sure what more there is to say...

Use a tag binding to get the tag's value.
Then add a map transform to map the possible tag values to the string you want.

I am actually new to Ignition..but got it...thanks

I would use a case in an expression binding. Only transform if you need to, otherwise use a single binding for performance.

Eg

case({tag}
, 1, "A" 
, 2, "B"
, 3, "C"
, 4, "D"
, 5, "E"
, "invalid"
)

Avoid the switch expression function like the plague for the only reason being that it's argument syntax is an abomination

5 Likes

I'm not a fan of map transforms anyway, I never use them.
But it is arguably the simplest way of doing this for a new ignition user, and the simpler to reason about.

I tried using case but everytime it shows error configuration.
but my values start with 0 and then it shows wrong result every time

You ll have to show us what you were trying for us to help

2 Likes

What Pascal said about direct tag bindings and Map Transforms is definitely the easiest way to go about this. It should look something like this;

Not the most performant though (but not nearly as bad as script transforms)

I say, design for performance and scalability where ever you can. That poor choice "it's only this one spot" multiplies and soon you have 100 "just one spot"s that contribute to reduced performance and reduced scalability of your project

Thank you....issue resolved