# numberFormat info

**URL:** <https://forum.inductiveautomation.com/t/numberformat-info/5608>\
**Category:** Ignition\
**Created:** [December 20, 2012, 9:01pm UTC](https://forum.inductiveautomation.com/t/numberformat-info/5608 "2012-12-20T21:01:30Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![cacordova](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@cacordova](https://forum.inductiveautomation.com/u/cacordova)\
**Post date:** [December 20, 2012, 9:01pm UTC](https://forum.inductiveautomation.com/t/numberformat-info/5608/1 "2012-12-20T21:01:30Z")

</div>

i’m testing the numberFormat and i used the example on the manual  
numberFormat(34.8, “#0.00’%’”)

but i got an error saying

[quote]Traceback (most recent call last):

File “event:mouseClicked”, line 3, in

NameError: name ‘numberFormat’ is not defined

Ignition v7.5.3 (b1163)  
Java: Oracle Corporation 1.7.0\_05  
[/quote]

Why is that?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [December 20, 2012, 9:05pm UTC](https://forum.inductiveautomation.com/t/numberformat-info/5608/2 "2012-12-20T21:05:57Z")

</div>

You’re looking at a function from the expression language in the manual but trying to use it in scripting, which you can’t do.

You might want to look at formatting in Python: [docs.python.org/2/library/string … ing-syntax](http://docs.python.org/2/library/string.html#format-string-syntax)

[stackoverflow.com/search?q=python+number+format](http://stackoverflow.com/search?q=python+number+format)

---

<div class="post-metadata">

**Author:** ![cacordova](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@cacordova](https://forum.inductiveautomation.com/u/cacordova)\
**Post date:** [December 27, 2012, 5:46pm UTC](https://forum.inductiveautomation.com/t/numberformat-info/5608/3 "2012-12-27T17:46:11Z")

</div>

ok so i did it like this

`n = 33.33
n = str(int(n*100))+'%'
print n`

it worked on the console window, the output was 33%

but when i tried to do it to show on the table all i got was 33, why is that?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [December 27, 2012, 6:03pm UTC](https://forum.inductiveautomation.com/t/numberformat-info/5608/4 "2012-12-27T18:03:56Z")

</div>

How are you using the value in the table? Can you post the entire mouseClicked script?

It would help knowing exactly what you are trying to do.

---

<div class="post-metadata">

**Author:** ![cacordova](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@cacordova](https://forum.inductiveautomation.com/u/cacordova)\
**Post date:** [December 27, 2012, 6:21pm UTC](https://forum.inductiveautomation.com/t/numberformat-info/5608/5 "2012-12-27T18:21:16Z")

</div>

i’m trying to compute for the oee and i need the output on the table to show the percent sign

`a = 8.0/24
availability = str(int(a*100)) + '%'
event.source.parent.getComponent("Table").updateRow(0,{1:availability})`

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [December 27, 2012, 6:53pm UTC](https://forum.inductiveautomation.com/t/numberformat-info/5608/6 "2012-12-27T18:53:36Z")

</div>

Ok, I see. What is the datatype of the availability column in the table? If it is an integer than you will not see the %. In that case you can go into the table customizer and add a suffix or number format on that column.

---

<div class="post-metadata">

**Author:** ![cacordova](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@cacordova](https://forum.inductiveautomation.com/u/cacordova)\
**Post date:** [December 27, 2012, 7:08pm UTC](https://forum.inductiveautomation.com/t/numberformat-info/5608/7 "2012-12-27T19:08:46Z")

</div>

oh cool i got it.

thanks 😃

---

<div class="post-metadata">

**Author:** ![dtamada](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@dtamada](https://forum.inductiveautomation.com/u/dtamada)\
**Post date:** [July 12, 2018, 4:42am UTC](https://forum.inductiveautomation.com/t/numberformat-info/5608/8 "2018-07-12T04:42:28Z")

</div>

Hi Kavin,

numberfomat(tag(“topic”+{Parameter Tag}),"#0")

i was trying to execute above expression in Label expression,but its not working.

Please check

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [July 12, 2018, 10:16pm UTC](https://forum.inductiveautomation.com/t/numberformat-info/5608/9 "2018-07-12T22:16:24Z")

</div>

@dtamada The error message you would’ve got entering this into an expression binding, “Unknown function: ‘numberfomat’” is your tip that you’ve misspelled the function name:  
It’s `numberFormat` (not `numberfomat`, missing “r”).

P.S. It’s usually better to start a new topic rather than resurrect a really old one. The original poster was trying to use the expression in scripting (where it doesn’t work).

---

<div class="post-metadata">

**Author:** ![dtamada](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@dtamada](https://forum.inductiveautomation.com/u/dtamada)\
**Post date:** [July 18, 2018, 9:15am UTC](https://forum.inductiveautomation.com/t/numberformat-info/5608/10 "2018-07-18T09:15:47Z")

</div>

Hi witman, thanks for the reply

I am using one custom properties.

1. PLC number

My tag expression is tag(“ PLC1/tag”+{ PLC number}) - it works,

Ex:

PLC1/tag\_1 = 12.0 (Tag type is Float4 )

I want to display only 12 in place of 12.0 in a Label Display

numberformat(tag(“PLC1/tag”+{ PLC number}),"#0") – doesn’t not work.

numberformat({PLC1/tag\_1},"#0") – it works

is it possible to write expression in scripting ? if not, how can I achieve above result?

Please suggest, thank you for the support.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 18, 2018, 11:44am UTC](https://forum.inductiveautomation.com/t/numberformat-info/5608/11 "2018-07-18T11:44:13Z")

</div>

tag() returns an object, not a number. Try:

```auto
numberformat(toDouble(tag(“PLC1/tag”+{PLC number})),"#0")

```

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [July 18, 2018, 3:35pm UTC](https://forum.inductiveautomation.com/t/numberformat-info/5608/12 "2018-07-18T15:35:36Z")

</div>

As @JordanCClark noted, you'l want to convert the tag object returned by `tag()` to a number. Also, based on this:

> [@dtamada](#):
>
> numberformat(tag(“PLC1/tag”+{ PLC number}),"#0") – doesn’t not work.
> 
> numberformat({PLC1/tag\_1},"#0") – it works

It looks like your first expression (that doesn't work) is missing an underscore after "tag" in the tag name--try:

```auto
numberFormat(toDouble(tag(“PLC1/tag_”+{PLC number})),"#0")

```

---

<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:** [July 18, 2018, 4:02pm UTC](https://forum.inductiveautomation.com/t/numberformat-info/5608/13 "2018-07-18T16:02:22Z")

</div>

Please, people! Stop recommending the tag() function. It exists for legacy compatibility. Use indirect tag bindings!

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [July 18, 2018, 4:09pm UTC](https://forum.inductiveautomation.com/t/numberformat-info/5608/14 "2018-07-18T16:09:56Z")

</div>

I was focused on what would keep your expressiong from evaluating, but as @pturmel notes, `tag()` gives poor performance. A better way to accomplish this would be via an Indirect Tag binding something like this:  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/2eab9503377b5d24a7317cd100d818907d9656a9.jpg)  
Then do the numberFormat on the value you get from the indirect binding.
