# Using tag data quality to set tag value

**URL:** <https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329>\
**Category:** Ignition\
**Created:** [May 7, 2022, 5:48pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329 "2022-05-07T17:48:03Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![coiceclimber](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@coiceclimber](https://forum.inductiveautomation.com/u/coiceclimber)\
**Post date:** [May 7, 2022, 5:48pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/1 "2022-05-07T17:48:03Z")

</div>

Hello, I am using Red Lion OPC connection to read and display the speed of a ski lift. The speed value controls the background color of lines, text labels and numeric labels. Obviously the ski lift must be powered up for the speed value to update. I am running the program right now and connecting to multiple ski lifts through the Red Lion OPC Server that is running. Several of the lifts that are not powered up are showing old speed values which are not correct and therefore the background colors are not correct. restarting the tag has no effect. All non-running ski lifts should have component backgrounds set to red. The data quality is showing as not connected which is what I would expect. I am trying to find a way to check the data quality and if it is anything other than good I want to force a value of 0 into the lift speed data tag so that all components bound to the lift speed value will update accordingly. I am guessing scripting is the way to do this but have had no luck yet. Any suggestions? Thanks in advance.

---

<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:** [May 7, 2022, 6:50pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/2 "2022-05-07T18:50:58Z")

</div>

> [@coiceclimber](#):
>
> Several of the lifts that are not powered up are showing old speed values which are not correct and therefore the background colors are not correct. restarting the tag has no effect.

That's a bit strange. Ignition offers a default of a red overlay if the tag value is bad. The Red Lion OPC server may not provide this information.

You didn't state whether your application is Vision or Perspective but you should be able to do what you want either way. In Perspective you could check if the tag's _Quality_ value changes when the unit goes offline. If it does then modify the binding on your speed readout to use an expression. Here I'm using a tag called _Ski lift speed_. A quality value of 192 means all is good with the tag:

 ![Skilift binding](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/3/939e72cfdfab8f379bb8765ef84fb5b200351a55.png)

```auto
if(
	{[default]Ski lift speed.Quality} = 192,
	{[default]Ski lift speed},
	"Offline"
)

```

Change `Offline` to `0` if you like but I'd prefer to know that comms was down rather than have a spoofed zero value. '-1' or '--' are other options.

**Improvement** (see Paul Griffith's post below)

```auto
if(
	isGood({[default]Ski lift speed}),
	{[default]Ski lift speed},
	"Offline"
)

```

---

<div class="post-metadata">

**Author:** ![coiceclimber](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@coiceclimber](https://forum.inductiveautomation.com/u/coiceclimber)\
**Post date:** [May 7, 2022, 8:52pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/3 "2022-05-07T20:52:18Z")

</div>

That worked…thanks!

Using Vision. I used your expression on a custom property called “speed” so if I understand correctly this checks if the OPC data tag LiftSpeed.Quality is 192, if it is then set the value of “speed” to LiftSpeed.value, otherwise set “speed” to offline or whatever I choose?

I am not using default red overlay because this makes screen unusable for user due to component placements and the size of the overlays.

Interesting that the Quality value was 600 when disconnected then when the expression executed it got set to 192 but the displayed value was whatever I put in the expression. Tested this on a currently running ski lift and it worked when disconnecting/reconnecting.

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:** [May 7, 2022, 8:57pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/4 "2022-05-07T20:57:29Z")

</div>

Your understanding is correct. See [Tag Quality and Overlays - Ignition User Manual 8.0 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC80/Tag+Quality+and+Overlays) for more on quality values and overlays. Code 600 isn’t listed! Expand the tag in _Tag Browser_ if you want to see all the properties available for interrogation - including _Quality_.

It may be worth your while spending a little time on getting the overlays working for you. It makes it clear what’s going on and the operator learns that it’s showing the last valid reading received which, in some circumstances, may be better than nothing.

---

<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:** [May 9, 2022, 3:09pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/5 "2022-05-09T15:09:06Z")

</div>

> [@Transistor](#):
>
> A quality value of 192 means all is good with the tag

I would generally recommend the `isGood()` function (`isGood({[default]Ski lift speed})` rather than an explicit check for only one tag quality.

---

<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:** [May 9, 2022, 3:43pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/6 "2022-05-09T15:43:32Z")

</div>

Thanks, Paul. I’ve used that in the past and forgot about it. It’s much cleaner and clearer.

---

<div class="post-metadata">

**Author:** ![coiceclimber](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@coiceclimber](https://forum.inductiveautomation.com/u/coiceclimber)\
**Post date:** [May 14, 2022, 10:08pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/7 "2022-05-14T22:08:31Z")

</div>

After further testing this is not working as I thought. Instead of setting the value of “speed” I am trying to change the visible property of a label.

this expression DOES NOT change the visible value when quality goes bad:

if(  
isGood({[default]Santiago\_LineSpeed.Quality}),  
{Root Container.Santiago\_Speed.visible} = true,  
false  
)

this expression DOES change the visible value to false when quality goes bad:

if(  
({[default]Santiago\_LineSpeed.Quality}) = 192,  
{Root Container.Santiago\_Speed.visible} = true,  
false  
)

but the visible property DOES NOT go back to true when quality goes from bad to good? I am currently using the “default” tag group with default values

I can only see “good” or “some kind of error” for data quality, cannot find a numerical value but based on above it seems logical that it is 192 when quality is good and when I tried 191 it set visible to false.

probably missing something very simple…thanks in advance

---

<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:** [May 14, 2022, 11:42pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/8 "2022-05-14T23:42:26Z")

</div>

I looks like you are trying to **assign** to the `.visible` property in the expression. Expressions don’t have assignments. Just operators and function calls. The result is assigned to the bound property. If you need to control the `visible` property, that is where the binding should be. (And you don’t need an `if` function to return true/false from a boolean expression. Just use the expression.)

---

<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:** [May 15, 2022, 7:05am UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/9 "2022-05-15T07:05:37Z")

</div>

To elaborate on Phil’s answer,  
`isGood({[default]Santiago_LineSpeed})`  
returns a value _true_ or _false_. (Note the lowercase constant names. Python uses _True, False, None_ but the expression language uses _true, false, null_.)

To use this to control the label’s visibility, create an expression binding on the label’s visibility. Set the binding to `isGood({[default]Santiago_LineSpeed})`  
and that’s it!

Tip: please use the `</>` code formatting button when posting code. This will preserve indentation and apply syntax highlighting.

---

<div class="post-metadata">

**Author:** ![coiceclimber](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@coiceclimber](https://forum.inductiveautomation.com/u/coiceclimber)\
**Post date:** [May 18, 2022, 8:39pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/10 "2022-05-18T20:39:43Z")

</div>

Thanks for the replies!

tried Transistor's method for controlling visibility...

> To use this to control the label’s visibility, create an expression binding on the label’s visibility. Set the binding to `isGood({[default]Santiago_LineSpeed.Quality})`\*  
> \*\> and that’s it!

This did not work. The data tag quality was good, I unplugged the network and the quality went bad but the visibility never changed? I tried the initial setting of the label's visibility property at both true and false, neither made a difference.

Seems so simple...what am I missing?

---

<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:** [May 18, 2022, 8:54pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/11 "2022-05-18T20:54:01Z")

</div>

We can’t tell you what you’re missing if you don’t show us what you did.

---

<div class="post-metadata">

**Author:** ![coiceclimber](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@coiceclimber](https://forum.inductiveautomation.com/u/coiceclimber)\
**Post date:** [May 18, 2022, 8:59pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/12 "2022-05-18T20:59:00Z")

</div>

Sorry, new to forum and still learning the standard protocols used…

I used:

isGood({[default]Santiago\_LineSpeed.Quality})

as an expression in the binding of the label visibility and it did not change the visibility of the label when the data quality went from good to bad.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [May 18, 2022, 9:00pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/13 "2022-05-18T21:00:23Z")

</div>

> [@coiceclimber](#):
>
> isGood({[default]Santiago\_LineSpeed.Quality})

Try dropping the .quality.

```auto
isGood({[default]Santiago_LineSpeed})

```

---

<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:** [May 18, 2022, 9:01pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/14 "2022-05-18T21:01:27Z")

</div>

That was my fault. I’ll edit my posts above. I forgot to take out the `.Quality` when I converted to `isGood` function.

Thanks.

---

<div class="post-metadata">

**Author:** ![coiceclimber](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@coiceclimber](https://forum.inductiveautomation.com/u/coiceclimber)\
**Post date:** [May 18, 2022, 9:13pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/15 "2022-05-18T21:13:26Z")

</div>

Dropping the .quality does the opposite of what I would expect. The Santiago\_LineSpeed is active and valid but the visibility of the label is now false, shouldn’t it be true?

---

<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:** [May 18, 2022, 9:21pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/16 "2022-05-18T21:21:12Z")

</div>

Q1. What is the tag’s _Quality_ value? (Check in the tag browser.)  
Q2. What is the value of the label’s _Visible_ property. (Check in the Vision Property Editor.)  
Q3. Is there a link icon on the label’s _Visible_ property.

---

<div class="post-metadata">

**Author:** ![coiceclimber](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@coiceclimber](https://forum.inductiveautomation.com/u/coiceclimber)\
**Post date:** [May 18, 2022, 9:26pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/17 "2022-05-18T21:26:35Z")

</div>

Q1: Good  
Q2: False  
Q3: Yes, it is where I clicked to enter the expression

---

<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:** [May 18, 2022, 9:30pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/18 "2022-05-18T21:30:22Z")

</div>

Q4: Are you 100% certain you’re using the right tag path and the right provider ? 😃

---

<div class="post-metadata">

**Author:** ![coiceclimber](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@coiceclimber](https://forum.inductiveautomation.com/u/coiceclimber)\
**Post date:** [May 18, 2022, 9:31pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/19 "2022-05-18T21:31:27Z")

</div>

Yes, only have the Default tag provider in this project and a small number of tags.

---

<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:** [May 18, 2022, 9:32pm UTC](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329/20 "2022-05-18T21:32:22Z")

</div>

I’m afraid you’re gonna have to start showing us screenshots.

[Next page](https://forum.inductiveautomation.com/t/using-tag-data-quality-to-set-tag-value/59329.md?page=2)
