# Float and/or string formatting

**URL:** <https://forum.inductiveautomation.com/t/float-and-or-string-formatting/10292>\
**Category:** General Discussion\
**Created:** [July 29, 2015, 7:27pm UTC](https://forum.inductiveautomation.com/t/float-and-or-string-formatting/10292 "2015-07-29T19:27:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerry101](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@jerry101](https://forum.inductiveautomation.com/u/jerry101)\
**Post date:** [July 29, 2015, 7:27pm UTC](https://forum.inductiveautomation.com/t/float-and-or-string-formatting/10292/1 "2015-07-29T19:27:53Z")

</div>

Trying to format floats to the text property of a label. I am seeing examples for Python using numberFormat but this does not exist. Is there a namespace I need to import? Format example “{#,##0.00}” What is the best method to format a string or float in the script editor?

---

<div class="post-metadata">

**Author:** ![Duffanator](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/duffanator/32/3560_2.png) [@Duffanator](https://forum.inductiveautomation.com/u/Duffanator)\
**Post date:** [July 29, 2015, 7:48pm UTC](https://forum.inductiveautomation.com/t/float-and-or-string-formatting/10292/2 "2015-07-29T19:48:12Z")

</div>

Click on the binding button next to the text property and use an expression binding, then put the following code in the expression area:

```auto
numberFormat({Path/To/Tag}, "#,##0.00")
```

Path/To/Tag is your tag path, obviously. And anything in the formatting that is a # is optional, places with 0’s will always be displayed.

---

<div class="post-metadata">

**Author:** ![jerry101](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@jerry101](https://forum.inductiveautomation.com/u/jerry101)\
**Post date:** [July 29, 2015, 9:52pm UTC](https://forum.inductiveautomation.com/t/float-and-or-string-formatting/10292/3 "2015-07-29T21:52:29Z")

</div>

I am not writing to the label from a tag. I am pulling the text from a column in a table via script.

On “propertyChange” of the table  
table = event.source.data  
event.source.parent.getComponent(‘Label1’).text = str(table.getValueAt(0, ‘Col1’))

I was trying to format when writing back to the label.

I tried as your suggestion and used the expression binding to the label:  
numberFormat(toFloat({Root Container.Label1.text}), “#,##0.00”)

This worked!
