# Displaying text based on a tag value

**URL:** <https://forum.inductiveautomation.com/t/displaying-text-based-on-a-tag-value/62969>\
**Category:** Ignition\
**Created:** [August 12, 2022, 7:18pm UTC](https://forum.inductiveautomation.com/t/displaying-text-based-on-a-tag-value/62969 "2022-08-12T19:18:01Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![IvanP](https://avatars.discourse-cdn.com/v4/letter/i/74df32/32.png) [@IvanP](https://forum.inductiveautomation.com/u/IvanP)\
**Post date:** [August 12, 2022, 7:18pm UTC](https://forum.inductiveautomation.com/t/displaying-text-based-on-a-tag-value/62969/1 "2022-08-12T19:18:01Z")

</div>

I’m looking to display text of my step description based on a tag value for the current step my machine is in using a text field.

For example, if the tag RXStep (which is bound to a PLC tag reading in an integer for the step a specific machine is in) reads 0 then print “Step: 0 Idle”.

I tried using If statements in Expression tab of the text field property binding window but keep getting errors no matter how I formatted them.

if ({Reactor\_Status.RXStep} = 0, “Step: 0 Idle”)  
if ({Reactor\_Status.RXStep} = 1, “Step: 1 Pressurize”)  
if ({Reactor\_Status.RXStep} = 2, “Step: 2 Leak Test”)  
if ({Reactor\_Status.RXStep} = 3, “Step: 3 Calculate Product Qty”)  
etc…

I have about 40 different steps. Is there a away to do this with a text field or better way to do this? I’ve looked at several forums but found nothing similar. Thanks!

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 12, 2022, 7:19pm UTC](https://forum.inductiveautomation.com/t/displaying-text-based-on-a-tag-value/62969/2 "2022-08-12T19:19:40Z")

</div>

Is this Vision, or Perspective? Do you expect to need to add additional step labels frequently/ever?

---

<div class="post-metadata">

**Author:** ![IvanP](https://avatars.discourse-cdn.com/v4/letter/i/74df32/32.png) [@IvanP](https://forum.inductiveautomation.com/u/IvanP)\
**Post date:** [August 12, 2022, 7:33pm UTC](https://forum.inductiveautomation.com/t/displaying-text-based-on-a-tag-value/62969/3 "2022-08-12T19:33:04Z")

</div>

Vision. No, these steps will likely never change.

---

<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:** [August 12, 2022, 7:39pm UTC](https://forum.inductiveautomation.com/t/displaying-text-based-on-a-tag-value/62969/4 "2022-08-12T19:39:35Z")

</div>

You could use nested if statements but you’d need commas at the end of each line and closing brackets. Something like,

```auto
if ({Reactor_Status.RXStep} = 0, "Step: 0 Idle"),
if ({Reactor_Status.RXStep} = 1, "Step: 1 Pressurize"),
if ({Reactor_Status.RXStep} = 2, "Step: 2 Leak Test"),
if ({Reactor_Status.RXStep} = 3, "Step: 3 Calculate Product Qty"),
etc., etc.,
"Step: 40 Last step"
))))))))))))))))))))))))))))))))))))))))))))))))

```

The `case` function would be much easier:

```auto
case({Reactor_Status.RXStep}
  0, "Step: 0 Idle",
  1, "Step: 1 Pressurize",
  2, "Step: 2 Leak Test",
  3, "Step: 3 Calculate Product Qty",
  etc., etc.,
  "Step: 40 Last step" // default
)

```

[https://docs.inductiveautomation.com/display/DOC81/case](https://docs.inductiveautomation.com/display/DOC81/case)

* * *

Tip: When posting code, select the block of code and press the \</\> button to format it. It will preserve indentation and do some syntax highlighting for you. It also prevents the forum engine putting in fancy “ ” inverted commas which have to be edited out when copying your post.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 12, 2022, 7:41pm UTC](https://forum.inductiveautomation.com/t/displaying-text-based-on-a-tag-value/62969/5 "2022-08-12T19:41:53Z")

</div>

So, if you’re only doing this once, I like the `case` statement, or if you might want additional customization with each step, you can use the [Style Customizer](https://docs.inductiveautomation.com/display/DOC81/Vision+Component+Customizers#VisionComponentCustomizers-StyleCustomizer) to bind arbitrary component properties (including text) to a driving property.

You could also store a dataset on a tag/client tag somewhere and use the `lookup` expression; that would allow you to update the text in one place (if you’re using this label in multiple windows).

---

<div class="post-metadata">

**Author:** ![IvanP](https://avatars.discourse-cdn.com/v4/letter/i/74df32/32.png) [@IvanP](https://forum.inductiveautomation.com/u/IvanP)\
**Post date:** [August 12, 2022, 7:54pm UTC](https://forum.inductiveautomation.com/t/displaying-text-based-on-a-tag-value/62969/6 "2022-08-12T19:54:39Z")

</div>

Thanks so much! I will try these.

---

<div class="post-metadata">

**Author:** ![IvanP](https://avatars.discourse-cdn.com/v4/letter/i/74df32/32.png) [@IvanP](https://forum.inductiveautomation.com/u/IvanP)\
**Post date:** [August 12, 2022, 8:29pm UTC](https://forum.inductiveautomation.com/t/displaying-text-based-on-a-tag-value/62969/7 "2022-08-12T20:29:59Z")

</div>

I tried the case statement just to test. I copied it exactly as shown below in the Expression tab of the property binding: text field window. I keep getting “Syntax Error on Token: ‘LONG CONST’ (Line 2 , Char 3)” error. Any ideas what could cause this? Are you able to use a tag as the value to inspect? I couldn’t find any examples using a tag instead of a constant.

case({Reactor\_Status.RXStep}  
0, “Step: 0 Idle”,  
1, “Step: 1 Pressurize”,  
2, “Step: 2 Leak Test”,  
3, “Step: 3 Calculate Product Qty”,  
“Bad!”  
)

I also tried the style customizer, the only thing with the is that I would like one line of text to show if possible. The style customizer shows all the steps at once and takes up too much room.

Thanks again!

---

<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:** [August 12, 2022, 9:22pm UTC](https://forum.inductiveautomation.com/t/displaying-text-based-on-a-tag-value/62969/8 "2022-08-12T21:22:27Z")

</div>

> [@IvanP](#):
>
> Any ideas what could cause this?

You haven't formatted your code properly again. (Re-read the tip in my previous post.) As a result we don't know if you have got “Step: 0 Idle” with "66 - 99" quotation marks or (what you should have) `"Step: 0 Idle"` with plain ASCII double-quotes.

Please edit both posts with the 🖉 edit link and then select any code blocks and press the \</\> button to format it. Check that the quote characters are the actual ones in your expression. Someone should be able to find the problem then.

---

<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:** [August 12, 2022, 10:54pm UTC](https://forum.inductiveautomation.com/t/displaying-text-based-on-a-tag-value/62969/9 "2022-08-12T22:54:42Z")

</div>

You're missing the first comma

Edit  
This one

```python
case({Reactor_Status.RXStep}, <---
   0, 'Step: 0 Idle',
   1, 'Step: 1 Pressurise',
   2, 'Step: 2 Leak Test',
   3, 'Step: 3 Calculate Product Qty',
   'Bad!'
)

```

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [August 13, 2022, 11:09am UTC](https://forum.inductiveautomation.com/t/displaying-text-based-on-a-tag-value/62969/10 "2022-08-13T11:09:23Z")

</div>

I had made a template for such things. Feel free to use if you find it helpful.

[Step Indicator Example.zip](https://forum.inductiveautomation.com/uploads/short-url/hBozWcgPPotJoZR6nQSfz63vlhY.zip) (4.8 KB)

[https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/2/e2c6a5a24f88ee5c7e777f4cad5261d867dccb9b.mp4](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/2/e2c6a5a24f88ee5c7e777f4cad5261d867dccb9b.mp4)
