# Unexpected Format Expression Behavior

**URL:** <https://forum.inductiveautomation.com/t/unexpected-format-expression-behavior/75650>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [June 28, 2023, 2:36pm UTC](https://forum.inductiveautomation.com/t/unexpected-format-expression-behavior/75650 "2023-06-28T14:36:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 28, 2023, 2:36pm UTC](https://forum.inductiveautomation.com/t/unexpected-format-expression-behavior/75650/1 "2023-06-28T14:36:50Z")

</div>

Would someone check me on this? Ignition Version 8.1.24.

When adding a format transform using a pattern with the % symbol the value is automatically multiplied by 100. I would expect the return to just be the pattern with the % tacked on.

Is/was this a bug that’s been addressed am I just can’t find reference to it, or is it expected behavior??

---

<div class="post-metadata">

**Author:** ![djs](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@djs](https://forum.inductiveautomation.com/u/djs)\
**Post date:** [June 28, 2023, 2:47pm UTC](https://forum.inductiveautomation.com/t/unexpected-format-expression-behavior/75650/2 "2023-06-28T14:47:38Z")

</div>

Same behavior on 8.1.20:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/4/44ef0ecd24c0cd3cfb99d6fc11e6d18ec572d59a.png)

Not sure if it's a bug, but I agree, it's not what I would expect...

---

<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:** [June 28, 2023, 2:51pm UTC](https://forum.inductiveautomation.com/t/unexpected-format-expression-behavior/75650/3 "2023-06-28T14:51:49Z")

</div>

Oh, yea, I encountered that before !  
Made me go "huh ?"

---

<div class="post-metadata">

**Author:** ![avaughn](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/avaughn/32/38972_2.png) [@avaughn](https://forum.inductiveautomation.com/u/avaughn)\
**Post date:** [June 28, 2023, 2:51pm UTC](https://forum.inductiveautomation.com/t/unexpected-format-expression-behavior/75650/4 "2023-06-28T14:51:54Z")

</div>

This is expected behavior. The user manual page on [Format Transforms](https://docs.inductiveautomation.com/display/DOC81/Format+Transform) provides an example of the formatting that gets applied when using %.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 28, 2023, 3:08pm UTC](https://forum.inductiveautomation.com/t/unexpected-format-expression-behavior/75650/5 "2023-06-28T15:08:47Z")

</div>

I’ll accept that, but just seems a bit of an odd choice to me, especially considering you can select the Percent format, which I would expect to have this behavior.

Oh well now I know.

---

<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:** [June 28, 2023, 3:11pm UTC](https://forum.inductiveautomation.com/t/unexpected-format-expression-behavior/75650/6 "2023-06-28T15:11:21Z")

</div>

That doc page talks about the `percent` format for numeric types, not about putting a `%` sign in a pattern format.  
That behavior is highly unintuitive.

---

<div class="post-metadata">

**Author:** ![avaughn](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/avaughn/32/38972_2.png) [@avaughn](https://forum.inductiveautomation.com/u/avaughn)\
**Post date:** [June 28, 2023, 3:23pm UTC](https://forum.inductiveautomation.com/t/unexpected-format-expression-behavior/75650/7 "2023-06-28T15:23:34Z")

</div>

I'll admit, I did read through the OP a bit too quickly. However, checking the [formatting reference](https://docs.inductiveautomation.com/display/DOC81/Data+Type+Formatting+Reference) page in the user manual also indicates the behavior is expected.

Edit: Also, the last example in the table shows the pattern that should be used to not multiply the input by 100.

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

---

<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:** [June 28, 2023, 4:28pm UTC](https://forum.inductiveautomation.com/t/unexpected-format-expression-behavior/75650/8 "2023-06-28T16:28:09Z")

</div>

> [@pascal.fragnoud](#):
>
> That behavior is highly unintuitive.

Take it up with Java:  
[https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/DecimalFormat.html](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/DecimalFormat.html)

| Symbol | Location | Localized? | Meaning |
| --- | --- | --- | --- |
| `0` | Number | Yes | Digit |
| `#` | Number | Yes | Digit, zero shows as absent |
| `.` | Number | Yes | Decimal separator or monetary decimal separator |
| `-` | Number | Yes | Minus sign |
| `,` | Number | Yes | Grouping separator |
| `%` | Prefix or suffix | Yes | Multiply by 100 and show as percentage |

---

<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:** [June 28, 2023, 4:29pm UTC](https://forum.inductiveautomation.com/t/unexpected-format-expression-behavior/75650/9 "2023-06-28T16:29:23Z")

</div>

> [@paul-griffith](#):
>
> Take it up with Java:

I tried to call them but it somehow multiplied the phone number by 42.

---

<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:** [June 28, 2023, 5:09pm UTC](https://forum.inductiveautomation.com/t/unexpected-format-expression-behavior/75650/10 "2023-06-28T17:09:15Z")

</div>

> [@pascal.fragnoud](#):
>
> I tried to call them but it somehow multiplied the phone number by 42.

That should have still yielded an answer (the _answer_). 😁
