Using parameter in tag path in an expression

hello,
I struggle to use a parameter in the tag path in an expression. Do you guy's know why it doesn't work if I do this for example:
if ({[Test SCADA Ignition]Kneder/Kneder{MixerWendel.knederNumber}/stat/hmiStatus} <= 9 , "Geblokkeerd", "onbekend").
I have this in an expression so that a label in a template gets a certain text to show in the designer. But it has to take the value of a specific tag I want to choose based on the parameter I pass. But the parameter isn't allowed in the expression.

Hope you guy's understand what I try here. if not, you can ask me and I will try to explain better.

image
I have 3 tag maps for 3 machines I use. and by passing a parameter in my template I should be able to tell my template which values of the machine it has to show

Did you try Indirect tag Binding?
create and pass a session/view parameter to the dynamic position to indirect binding.

yes I know the indirect tag binding and that works, but if I use that as far as I know I can't use my expression anymore and I need to show a certain text based of a value.
image
or is this possible with the indirect tag option?
image
this is the error I get

Oooo - you've changed the question.

Please post code, not picutres of code. See here:

when value is 15, what should be the output?

Better use elif

[Edit] This answer is irrelevant. It turns out that it's a Vision application.

Try this but be aware that you are nesting if statements and you may hit a limit.

if({value} <=  9, "Geblokkeerd ",
if({value} <= 19, "Storing ",
if({value} <= 29, "Interlock ",
if({value} <= 39, "Standby ",
                  "Invalid"
))))

sorry for that, this is the code im using:
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 9 , "Geblokkeerd",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 19 ,"Storing ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 29 ,"Interlock ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 39 ,"Standby ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 109 ,"Mengen ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 119 ,"Stoppen ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 129,"Voltooid ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 139 ,"Kneden ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 149 ,"Stoppen ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 159,"Wacht op bevestiging ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 169 ,"Voltooid ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 179 ,"Vooruit wendelen ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 189 ,"Achteruit wendelen ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 199 ,"Wendelen voltooid ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 209 ,"Knederkop tussen posities ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 219 ,"Knederkop beweegt omhoog ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 229 ,"Knederkop is boven ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 239 ,"Knederkop wacht op toestemming zakken ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 249 ,"Knederkop beweegt omlaag ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 259 ,"Knederkop is beneden ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 309 ,"Kuip ontgrendeld ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 319 ,"Kuip vergrendelen ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 329 ,"Kuip vergrendeld ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 339 ,"Kuip ontgrendelen ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 409 ,"Standby ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 419,"Kuip vergrendelen ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 429 ,"Wacht op recept ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 439 ,"Kop zakken",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 449 ,"Mengen ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 459 ,"Kneden ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 469 ,"Wendelen ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 479 ,"Kop omhoog ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 489 ,"Schoondraaien",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 499 ,"Kop omhoog ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 509 ,"Kuip ontgrendelen",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 519 ,"Voltooid ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 529 ,"Schoonmaak - Vergrendelen ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 539 ,"Schoonmaak - Kop Zakken ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 549 ,"Schoonmaak Actief ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 559 ,"Schoonmaak - Kop omhoog ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 569 ,"Schoonmaak - Ontgrendelen ",
if ({[Test SCADA Ignition]Kneder/Kneder2/stat/hmiStatus} <= 999 ,"Gepauzeerd","onbekend"))))))))))))))))))))))))))))))))))))))))))
this works but I want the number in the tag path to be a parameter so that the tag path changes.

And is there a more efficient way to make this because you're saying I'm nesting if statements? I didn't know how to make this work in any other way.

Kneder2 is a dynamic tag?
You can use indirect tag binding than you can use script transform.

if value<=9:
    return "Geblokkeerd"
if value<=19:
    return  "Storing"

There is no elif in Expression Language.
if(condition, trueReturn, falseReturn)

You're suggesting a script transform but there will be a performance hit with that.

https://docs.inductiveautomation.com/display/DOC81/if

I can't do it like you do for some reason. this is what I can do when I chose tag


I'm not able to choose direct or indirect as you can see. And the indirect option doesn't give me the option to do something with expression. As soon as I want to fill something in all of those option the other ones get deleted.

aren't you working in perspective or something?
because I'm working in vision

Create a custom property, indirectly bind your tag to it, and use the custom prop instead of the tag in your expression binding

1 Like

Yes, my answer is for Perspective. You need to add the appropriate tag to your question. (It's important.) Hit the pencil edit icon beside your post title.

1 Like

No transforms in vision. But you don't need it in this case.

Here are a few thoughts about the whole thing:

  1. You can use a custom property to hold the value of your tag, then reference that. This will allow you to use an indirect tag binding once, then do more things with the results.
  2. You can use the case function:
case(true,
	{view.custom.val} < 9, "9",
	{view.custom.val} < 14, "14",
	{view.custom.val} < 49, "49",
	{view.custom.val} < 53, "53",
	{view.custom.val} < 76, "76",
	...
	"default"
)

2 Likes