# Using parameter in tag path in an expression

**URL:** <https://forum.inductiveautomation.com/t/using-parameter-in-tag-path-in-an-expression/80126>\
**Category:** Ignition\
**Created:** [October 6, 2023, 7:09am UTC](https://forum.inductiveautomation.com/t/using-parameter-in-tag-path-in-an-expression/80126 "2023-10-06T07:09:39Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [October 6, 2023, 7:09am UTC](https://forum.inductiveautomation.com/t/using-parameter-in-tag-path-in-an-expression/80126/1 "2023-10-06T07:09:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [October 6, 2023, 7:12am UTC](https://forum.inductiveautomation.com/t/using-parameter-in-tag-path-in-an-expression/80126/2 "2023-10-06T07:12:06Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/5/75dc202a30fa764d21b267214a3181041ac28ba6.png)  
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

---

<div class="post-metadata">

**Author:** ![Learner\_Ignition](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Learner\_Ignition](https://forum.inductiveautomation.com/u/Learner_Ignition)\
**Post date:** [October 6, 2023, 7:23am UTC](https://forum.inductiveautomation.com/t/using-parameter-in-tag-path-in-an-expression/80126/3 "2023-10-06T07:23:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [October 6, 2023, 7:31am UTC](https://forum.inductiveautomation.com/t/using-parameter-in-tag-path-in-an-expression/80126/4 "2023-10-06T07:31:03Z")

</div>

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](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/6/a6316278a9d311670a8f9c646187d9513ce90fee.png)  
or is this possible with the indirect tag option?  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/5/45bc4556f5a4b69459533eb39408b8eaf144ec94.png)  
this is the error I get

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 6, 2023, 7:33am UTC](https://forum.inductiveautomation.com/t/using-parameter-in-tag-path-in-an-expression/80126/5 "2023-10-06T07:33:05Z")

</div>

Oooo - you've changed the question.

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

> [@Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831):
>
> This thread is intended as a short help file for all those struggling to post formatted code on the forum. Posting formatted code on the forum (and most others) is as simple as selecting the code and pressing the \</\> button. It works the same as applying Bold or Italic styles to your document. It preserves indentation and applies syntax highlighting. [How to post code]

---

<div class="post-metadata">

**Author:** ![Learner\_Ignition](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Learner\_Ignition](https://forum.inductiveautomation.com/u/Learner_Ignition)\
**Post date:** [October 6, 2023, 7:37am UTC](https://forum.inductiveautomation.com/t/using-parameter-in-tag-path-in-an-expression/80126/6 "2023-10-06T07:37:37Z")

</div>

when value is 15, what should be the output?

Better use `elif`

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 6, 2023, 7:46am UTC](https://forum.inductiveautomation.com/t/using-parameter-in-tag-path-in-an-expression/80126/7 "2023-10-06T07:46:46Z")

</div>

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

 ![Lookup expression](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/3/93481ec091065b276ef94264b039fc35b30d4328.png)

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

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

```

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [October 6, 2023, 7:47am UTC](https://forum.inductiveautomation.com/t/using-parameter-in-tag-path-in-an-expression/80126/8 "2023-10-06T07:47:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 6, 2023, 7:48am UTC](https://forum.inductiveautomation.com/t/using-parameter-in-tag-path-in-an-expression/80126/9 "2023-10-06T07:48:02Z")

</div>

> [@Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831):
>
> This thread is intended as a short help file for all those struggling to post formatted code on the forum. Posting formatted code on the forum (and most others) is as simple as selecting the code and pressing the \</\> button. It works the same as applying Bold or Italic styles to your document. It preserves indentation and applies syntax highlighting. [How to post code]

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [October 6, 2023, 7:49am UTC](https://forum.inductiveautomation.com/t/using-parameter-in-tag-path-in-an-expression/80126/10 "2023-10-06T07:49:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Learner\_Ignition](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Learner\_Ignition](https://forum.inductiveautomation.com/u/Learner_Ignition)\
**Post date:** [October 6, 2023, 7:52am UTC](https://forum.inductiveautomation.com/t/using-parameter-in-tag-path-in-an-expression/80126/11 "2023-10-06T07:52:08Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 6, 2023, 7:53am UTC](https://forum.inductiveautomation.com/t/using-parameter-in-tag-path-in-an-expression/80126/12 "2023-10-06T07:53:16Z")

</div>

> [@Learner\_Ignition](#):
>
> Better use `elif`

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](https://docs.inductiveautomation.com/display/DOC81/if)

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [October 6, 2023, 8:50am UTC](https://forum.inductiveautomation.com/t/using-parameter-in-tag-path-in-an-expression/80126/13 "2023-10-06T08:50:50Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/1/e1af1e624a201f85b600d198a66823a97a1c4f62.png)  
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

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [October 6, 2023, 8:56am UTC](https://forum.inductiveautomation.com/t/using-parameter-in-tag-path-in-an-expression/80126/14 "2023-10-06T08:56:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 6, 2023, 8:58am UTC](https://forum.inductiveautomation.com/t/using-parameter-in-tag-path-in-an-expression/80126/15 "2023-10-06T08:58:13Z")

</div>

> [@Stef\_Velers](#):
>
> because I'm working in vision

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.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 6, 2023, 8:59am UTC](https://forum.inductiveautomation.com/t/using-parameter-in-tag-path-in-an-expression/80126/16 "2023-10-06T08:59:11Z")

</div>

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:

```auto
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"
)

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/7/e734a5977d2c0a62138f668373d85da5834e64ed.png)
