# Perspective Indirect formatting on a label

**URL:** <https://forum.inductiveautomation.com/t/perspective-indirect-formatting-on-a-label/39929>\
**Category:** Ignition\
**Created:** [October 22, 2020, 5:50pm UTC](https://forum.inductiveautomation.com/t/perspective-indirect-formatting-on-a-label/39929 "2020-10-22T17:50:39Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![bwhite](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bwhite/32/7112_2.png) [@bwhite](https://forum.inductiveautomation.com/u/bwhite)\
**Post date:** [October 22, 2020, 5:50pm UTC](https://forum.inductiveautomation.com/t/perspective-indirect-formatting-on-a-label/39929/1 "2020-10-22T17:50:39Z")

</div>

I am working on putting together a generic label to use with any of my analog values. On my tags, I always use the numeric properties and fill in the units and format string. I want to use this in a embedded view in perspective similar to the way I use it in Vision on a template. Is there a way to have the format bound to a parameter?

---

<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:** [October 22, 2020, 7:10pm UTC](https://forum.inductiveautomation.com/t/perspective-indirect-formatting-on-a-label/39929/2 "2020-10-22T19:10:24Z")

</div>

I’m sure there’s probably a better way to manage this, but this solution here works (but obviously update the path as needed for you project). This is an Expression binding on `Label.props.text` against a Tag in my project. It obtains the tag’s `value`, `formatString`, and `engUnit` and uses those pieces to build a String.

```auto
numberFormat(tag("[default]Experimentation/IntRepl"), tag("[default]Experimentation/IntRepl.formatString")) + tag("[default]Experimentation/IntRepl.engUnit")

```

Result:  
`8.00psi`

If you want the format bound to a parameter instead of the format used on the Tag, you should store the format as a string in a property somewhere, and instead of using the Expression above you would replace the format portion with a reference to your custom property:

```auto
numberFormat(tag("[default]Experimentation/IntRepl"), {self.custom.formatString}) + tag("[default]Experimentation/IntRepl.engUnit")

```

---

<div class="post-metadata">

**Author:** ![bwhite](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bwhite/32/7112_2.png) [@bwhite](https://forum.inductiveautomation.com/u/bwhite)\
**Post date:** [October 22, 2020, 8:20pm UTC](https://forum.inductiveautomation.com/t/perspective-indirect-formatting-on-a-label/39929/3 "2020-10-22T20:20:11Z")

</div>

Thank you cmallonee! That worked.

---

<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:** [October 22, 2020, 8:25pm UTC](https://forum.inductiveautomation.com/t/perspective-indirect-formatting-on-a-label/39929/4 "2020-10-22T20:25:15Z")

</div>

For the sake of performance you should replace the `tag()` calls with indirect tag bindings - that is, make a structure in `view.custom` something like:

```json
{
  "tagPath": "${some String}",
  "formatString": <indirect binding to formatString>,
  "engUnit": <indirect binding to engUnit>,
}

```

For best results, make these properties private (right click menu) so that the intermediate values aren’t synchronized to the front-end. Then mash them together in a `numberFormat` expression as Cody did above.

---

<div class="post-metadata">

**Author:** ![bwhite](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bwhite/32/7112_2.png) [@bwhite](https://forum.inductiveautomation.com/u/bwhite)\
**Post date:** [October 23, 2020, 12:31pm UTC](https://forum.inductiveautomation.com/t/perspective-indirect-formatting-on-a-label/39929/5 "2020-10-23T12:31:19Z")

</div>

Thank you PGriffith. I had already put it in the meta properties. I didn’t know about making it private, though. I will do that.

---

<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:** [October 23, 2020, 3:51pm UTC](https://forum.inductiveautomation.com/t/perspective-indirect-formatting-on-a-label/39929/6 "2020-10-23T15:51:09Z")

</div>

The `custom` category is where we recommend you put it. There are some properties present in `meta` that we do not expose for public use. If you happen to provide a key in `meta` which matches one of the properties we’ve put in place there you could overwrite important values, or ignore security on that property and expose it in the web browser.

---

<div class="post-metadata">

**Author:** ![Thomas\_Kirchmeyr](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@Thomas\_Kirchmeyr](https://forum.inductiveautomation.com/u/Thomas_Kirchmeyr)\
**Post date:** [March 23, 2022, 8:05am UTC](https://forum.inductiveautomation.com/t/perspective-indirect-formatting-on-a-label/39929/7 "2022-03-23T08:05:11Z")

</div>

Is there a clean solution for this in 2022?

Why isn’t there a tickbox to enable the EngUnit in Label, Text, …?

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [August 13, 2023, 1:12pm UTC](https://forum.inductiveautomation.com/t/perspective-indirect-formatting-on-a-label/39929/8 "2023-08-13T13:12:46Z")

</div>

> [@paul-griffith](#):
>
> ```auto
> {
> "tagPath": "${some String}",
> "formatString": <indirect binding to formatString>,
> "engUnit": <indirect binding to engUnit>,
> }
> 
> ```

in the above case, did you mean tagPath, is actually the "value" returned by using indirect binding on the tagPath.

Otherwise, you mash up these items using tag() function. Which you also said not to use tag() for best practice.

that would be like  
numberFormat(tagValue, formatString) + " " + engUnit  
??

---

<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:** [August 13, 2023, 8:55pm UTC](https://forum.inductiveautomation.com/t/perspective-indirect-formatting-on-a-label/39929/9 "2023-08-13T20:55:08Z")

</div>

If you have a tag path, you can just use `{tag_path}` in an expression to read it and get its value. No reason to use `tag()` here.  
The reason for the intermediate property is to build the path here if you need to build it from several pieces.  
So you could use `numberFormat(tagValue, formatString)` or `numberFormat({tagPath}, formatString)`.

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [August 13, 2023, 9:24pm UTC](https://forum.inductiveautomation.com/t/perspective-indirect-formatting-on-a-label/39929/10 "2023-08-13T21:24:34Z")

</div>

> [@pascal.fragnoud](#):
>
> `numberFormat({tagPath}, formatString)`.

if my tagpath = {prefix}{tagName}

Can we still do the above, without using tag()?  
I tried but didn't work.. as is.

---

<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 13, 2023, 10:15pm UTC](https://forum.inductiveautomation.com/t/perspective-indirect-formatting-on-a-label/39929/11 "2023-08-13T22:15:21Z")

</div>

Indirect tag binding.

---

<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:** [August 13, 2023, 10:48pm UTC](https://forum.inductiveautomation.com/t/perspective-indirect-formatting-on-a-label/39929/12 "2023-08-13T22:48:03Z")

</div>

Yes, you build the full path somewhere else:

> [@pascal.fragnoud](#):
>
> The reason for the intermediate property is to build the path here if you need to build it from several pieces.

Or you use an indirect tag binding and then add a transform.  
I didn't read the whole thing so I'm not sure about the use case, but one of those solutions is probably what you're looking for.

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [August 13, 2023, 11:18pm UTC](https://forum.inductiveautomation.com/t/perspective-indirect-formatting-on-a-label/39929/13 "2023-08-13T23:18:20Z")

</div>

Yes, thanks, I was trying to not use transform as much as I could. As with this initial post. I ended with having multiple property and mash them than use transform.

I was hoping I can numberFormat({prefix}{tagName}, formatString)  
So I do not have to read tag like below.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/b/5b8efafc3cf96c4697e44b0f2d01a06eb29d2498.png)

and then mash them up like this.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/7/f77bd18959997ed134c5a9679536c064bb9e9ff4.png)  
But I think this is good.  
🙂

---

<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:** [August 13, 2023, 11:20pm UTC](https://forum.inductiveautomation.com/t/perspective-indirect-formatting-on-a-label/39929/14 "2023-08-13T23:20:22Z")

</div>

> [@Eugene49](#):
>
> I was hoping I can numberFormat({prefix}{tagName}, formatString)

No, you need an indirect tag binding into another property. The indirection combines the prefix and the tag name and then retrieves the actual value. You need to provide the actual numeric value to `numberFormat`.

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [August 13, 2023, 11:24pm UTC](https://forum.inductiveautomation.com/t/perspective-indirect-formatting-on-a-label/39929/15 "2023-08-13T23:24:09Z")

</div>

Yes, I did that to get the tagValue.

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

In the end I did, indirect binding, plus, mash them up using expression without transform.

VS (in contrast to)

indirect binding + transform.

I guess both does not differ in terms of performance.

---

<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:** [August 13, 2023, 11:31pm UTC](https://forum.inductiveautomation.com/t/perspective-indirect-formatting-on-a-label/39929/16 "2023-08-13T23:31:33Z")

</div>

Very little difference, true, I suspect. Unless you need that tag value for other purposes, in which case getting it in one place is best.
