# Tag binding, adding transform, if value = 0

**URL:** <https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 5, 2023, 2:49am UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245 "2023-01-05T02:49:19Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [January 5, 2023, 2:49am UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245/1 "2023-01-05T02:49:19Z")

</div>

Hello all,

If a tag returns a zero, I would like the label to display nothing instead of a zero. I used a transform to format the decimal numbers such as '##.#0'.

I was attempting to add an Expression transform to that but I am not savvy enough with the syntax.

If tag value = 0, then label value = nothing.

thanks,

---

<div class="post-metadata">

**Author:** ![user77](https://avatars.discourse-cdn.com/v4/letter/u/a183cd/32.png) [@user77](https://forum.inductiveautomation.com/u/user77)\
**Post date:** [January 5, 2023, 3:00am UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245/2 "2023-01-05T03:00:04Z")

</div>

Hello mdemaris,

The manual section for Expression Language and Syntax should get you going.

[https://docs.inductiveautomation.com/display/DOC81/Expression+Language+and+Syntax](https://docs.inductiveautomation.com/display/DOC81/Expression+Language+and+Syntax)

But if you are still having issues, here is an example:

```auto
if ({Path/To/YourTag} = 0, "", {Path/To/YourTag}) 
if (evaluation, returns true, returns false)

```

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [January 5, 2023, 3:03am UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245/3 "2023-01-05T03:03:49Z")

</div>

Alternatively, you could also manage this in the transform of a pure Tag Binding:

```auto
return value if value != 0 else ""

```

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [January 5, 2023, 4:52pm UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245/4 "2023-01-05T16:52:23Z")

</div>

where 'value' is the path to tag?

@user77 I read through that but they don't give an example of the IF statement. Though I almost had it yesterday, going off my VBA knowledge, but I did not include the '( )' so I got an error. So that worked!

If I get the shorter stmt to work, I'll probably use that...less typing, less wordy.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [January 5, 2023, 5:11pm UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245/5 "2023-01-05T17:11:52Z")

</div>

No, in a Transform, the `value` variable is passed into the script. In the following example, I've modified the format a little bit because I'm not sure exactly how you configured your formatting. I also modified the script transform because after the formatting transform your value will actually be a string.

 ![Screenshot 2023-01-05 at 9.10.43 AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/0/b071bf44e631c0e21a885aaadbb64d3fdbc67ee5.png)

And then this is what non-zero values look like:

![Screenshot 2023-01-05 at 9.11.01 AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/4/74d67d761edfc5c45ef81228ada1caf345548de4.png)

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [January 5, 2023, 5:45pm UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245/6 "2023-01-05T17:45:17Z")

</div>

Ok, so we are talking about two different transforms. Using the Expression transform, @user77 provided the stmt for that, and using the Script transform, this is how that would work.

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [January 5, 2023, 6:12pm UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245/7 "2023-01-05T18:12:49Z")

</div>

Here is what I'm getting.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/b/8be6c1d1b4b025a4b8981f2c0e4d99a9ce843e8a.png)

same error if I remove the int() function.

null returned if I remove the int and float() functions.

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [January 5, 2023, 6:14pm UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245/8 "2023-01-05T18:14:48Z")

</div>

UNLESS! I set the format as you had it, '##.00', instead of '##.#0'

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [January 5, 2023, 6:15pm UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245/9 "2023-01-05T18:15:44Z")

</div>

Thank you @user77 and @cmallonee! Both of your suggestions work well!

---

<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:** [January 5, 2023, 6:22pm UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245/10 "2023-01-05T18:22:35Z")

</div>

`#0.00` is a safer format to force a `0` before the decimal point. It emphasises decimal rather than, say, `##.00` which would render `0.23` as `.23` which could be misread as `23`.  
Seeing `0.23` is much less ambiguous.

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [January 5, 2023, 6:26pm UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245/11 "2023-01-05T18:26:53Z")

</div>

I have one more question on formatting and transforms:

Is it possible to do a group transform without affecting the tags currently bound to the components?

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [January 5, 2023, 6:27pm UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245/12 "2023-01-05T18:27:17Z")

</div>

I don't understand the question.

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [January 5, 2023, 6:28pm UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245/13 "2023-01-05T18:28:29Z")

</div>

If I select 10 labels, all bound to separate tags, and would like to apply the same transforms to all 10, is this possible without the tag binding changing?

Yesterday I attempted this but all the tags were changed to the same one.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [January 5, 2023, 6:44pm UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245/14 "2023-01-05T18:44:42Z")

</div>

Oh, no; you're overwriting all the bindings with whatever configuration is displayed when you hit "Ok" or "Apply". There is no "Binding Configuration Merge" tool.

---

<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:** [January 5, 2023, 7:10pm UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245/15 "2023-01-05T19:10:41Z")

</div>

If you're gonna use a script transform anyway, you could do your formatting there as well:

```python
return "{:.2f}".format(value) if value != 0 else ""

```

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [January 5, 2023, 7:24pm UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245/16 "2023-01-05T19:24:27Z")

</div>

how would this render 101.9 versus 1.9 values?

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [January 5, 2023, 7:36pm UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245/17 "2023-01-05T19:36:15Z")

</div>

Like this:

 ![Screenshot 2023-01-05 at 11.36.01 AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/6/460b3a6bf526b8c92b0bb9ea496e643af3951922.png)

![Screenshot 2023-01-05 at 11.37.03 AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/e/3e1ea788c4774e7fd0b77c880a6bc1079356cbf5.png)

---

<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:** [January 5, 2023, 7:56pm UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245/18 "2023-01-05T19:56:46Z")

</div>

Just keep in mind that script transforms should be your last resort as they incur slightly higher performance penalties and load on the gateway which is important to manage particularly in large systems, but also good practice

---

<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:** [January 6, 2023, 5:54am UTC](https://forum.inductiveautomation.com/t/tag-binding-adding-transform-if-value-0/68245/19 "2023-01-06T05:54:58Z")

</div>

`.2f` means "display as a float with 2 digits after the dot".
