# Changing Label Properties based on Tag Values

**URL:** <https://forum.inductiveautomation.com/t/changing-label-properties-based-on-tag-values/88371>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [April 4, 2024, 6:54pm UTC](https://forum.inductiveautomation.com/t/changing-label-properties-based-on-tag-values/88371 "2024-04-04T18:54:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Craig](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Ryan\_Craig](https://forum.inductiveautomation.com/u/Ryan_Craig)\
**Post date:** [April 4, 2024, 6:54pm UTC](https://forum.inductiveautomation.com/t/changing-label-properties-based-on-tag-values/88371/1 "2024-04-04T18:54:43Z")

</div>

I am trying to create a label for an HMI that will say if a part passed, failed, or if the machine is running. I started by creating an expression binding on the text property of the label that looks like this:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/b/7bfe8f34281cf5bbeabd030961d7416824b39d5f.png)  
With this transformation script:

```auto
def transform(self, value, quality, timestamp):
	if value. Var1 == 0:
		value.text == 'TEST RUNNING'
	elif value.Var1 == 1 and value.Var2 == 1:
		value.text == 'TEST PASS'
	elif value.Var1 == 1 and value.Var2 == 0:
		value.text == 'TEST FAIL'

```

But I can't get it to return anything but null. I have tried to do this same thing but to change the color of the background but no luck.  
Any idea what I am doing wrong?

---

<div class="post-metadata">

**Author:** ![Noah\_Casey](https://avatars.discourse-cdn.com/v4/letter/n/e480ec/32.png) [@Noah\_Casey](https://forum.inductiveautomation.com/u/Noah_Casey)\
**Post date:** [April 4, 2024, 7:00pm UTC](https://forum.inductiveautomation.com/t/changing-label-properties-based-on-tag-values/88371/2 "2024-04-04T19:00:49Z")

</div>

You are not returning any value.

Try this:

```auto
def transform(self, value, quality, timestamp):
	if value.Var1 == 0:
		return('TEST RUNNING')
	elif value.Var1 == 1 and value.Var2 == 1:
		return('TEST PASS')
	elif value.Var1 == 1 and value.Var2 == 0:
		return('TEST FAIL')

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 4, 2024, 7:03pm UTC](https://forum.inductiveautomation.com/t/changing-label-properties-based-on-tag-values/88371/3 "2024-04-04T19:03:07Z")

</div>

Including `{this.props.text}` in your structure binding makes a circular reference. Perspective is pretty good about catching these, but not perfect. If it doesn't, it can bog down your gateway.

---

<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:** [April 4, 2024, 7:28pm UTC](https://forum.inductiveautomation.com/t/changing-label-properties-based-on-tag-values/88371/4 "2024-04-04T19:28:33Z")

</div>

You should be able to use a direct Expression binding.

```auto
// Ready PassFail Output
// ----- -------- ------
// False X TEST RUNNING
// True True TEST PASS
// True False TEST FAIL
if(!{[default]BurstTester/Instrument_Ready},
	'TEST RUNNING',
	if({[default]BurstTester/OverallPassFail},
	  'TEST PASS',
	  'TEST FAIL'
	)
)

```

---

<div class="post-metadata">

**Author:** ![Ryan\_Craig](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Ryan\_Craig](https://forum.inductiveautomation.com/u/Ryan_Craig)\
**Post date:** [April 4, 2024, 7:51pm UTC](https://forum.inductiveautomation.com/t/changing-label-properties-based-on-tag-values/88371/5 "2024-04-04T19:51:21Z")

</div>

After playing around with this a few ways, I wasn't able to get it to work completely. I would still get the null value returned.

---

<div class="post-metadata">

**Author:** ![Ryan\_Craig](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Ryan\_Craig](https://forum.inductiveautomation.com/u/Ryan_Craig)\
**Post date:** [April 4, 2024, 7:52pm UTC](https://forum.inductiveautomation.com/t/changing-label-properties-based-on-tag-values/88371/6 "2024-04-04T19:52:21Z")

</div>

This seems to work exactly how I needed it to. I may need to look into it more to get it to work with changing different text colors and backgrounds.

---

<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:** [April 4, 2024, 8:00pm UTC](https://forum.inductiveautomation.com/t/changing-label-properties-based-on-tag-values/88371/7 "2024-04-04T20:00:06Z")

</div>

> [@Ryan\_Craig](#):
>
> ... with changing different text colors and backgrounds.

Oh-oh!  
It might be time for a read of [High Performance HMI Techniques | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/ignition-modules/vision/common-tasks-in-vision/high-performance-hmitechniques).

In any case, you would copy the binding from the text property and apply it to the Style Classes and replace the text in the expression above with the style classes. (You wouldn't be applying colors directly in a binding now, would you?)

> **[Style Classes | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/ignition-modules/perspective/styles/style-classes)**
>
> A Style Class is a group of Style settings that are saved together. Style Classes can be applied to multiple components to provide consistency in design. A Style Class enables you to define style elements in one place, and then quickly apply that...

> **[Perspective Built-In Themes | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/ignition-modules/perspective/styles/perspective-built-in-themes)**
>
> Themes

---

<div class="post-metadata">

**Author:** ![Ryan\_Craig](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Ryan\_Craig](https://forum.inductiveautomation.com/u/Ryan_Craig)\
**Post date:** [April 4, 2024, 8:26pm UTC](https://forum.inductiveautomation.com/t/changing-label-properties-based-on-tag-values/88371/8 "2024-04-04T20:26:43Z")

</div>

Thanks for the help! I was able to get everything to work as intended after a little reading.
