# FormatNumber

{% hint style="info" %}
The **`FormatNumber()`** function converts a <mark style="color:blue;">number</mark> to <mark style="color:green;">text</mark> according to the specified format.

This function is NOT SQL compatible. For more information about SQL compatibility, see our [documentation](https://docs.wem.io/platform/~/changes/y5gAfiyi2fILzrLzUUHj/wemreference/sql-compatibility).
{% endhint %}

{% hint style="success" %}
Returns a new <mark style="color:green;">text</mark> string that is the formatted text representation of a number. \
Returns <mark style="color:red;">`Invalid expression`</mark> if <mark style="color:blue;">`number`</mark>is unknown or the indicated format is not valid for numeric values.&#x20;
{% endhint %}

### Syntax

<details>

<summary><code>FormatNumber(</code><mark style="color:blue;"><code>number</code></mark><code>,</code><mark style="color:blue;"><code>decimals</code></mark><code>,</code><mark style="color:blue;"><code>language</code></mark><code>)</code></summary>

`FormatNumber(123456.789, 2)`\
\=> `123456,78`  *(when the currentlanguage has the comma for decimal point)*

`FormatNumber(123456.789, 2, en_US)`\
\=> `123456.78` &#x20;

</details>

<details>

<summary><code>FormatNumber(</code><mark style="color:blue;"><code>number</code></mark><code>,</code><mark style="color:blue;"><code>decimals</code></mark><code>,</code><mark style="color:blue;"><code>grouping</code></mark><code>,</code><mark style="color:blue;"><code>language</code></mark><code>)</code></summary>

`FormatNumber(123456.789, 2, true)`\
\=> `123.456,78`  *(when the currentlanguage has the comma for decimal point)*

`FormatNumber(123456.789, 2, true, en_US)`\
\=> `123,456.78`

</details>

### Parameters

<table><thead><tr><th width="150">Name</th><th width="150">Type</th><th width="150" align="center">Required</th><th width="248.15953250810662">Description</th><th data-hidden>Required?</th></tr></thead><tbody><tr><td><mark style="color:blue;"><code>number</code></mark></td><td>numeric</td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2611">☑️</span></td><td>a value of any type.</td><td>yes</td></tr><tr><td><mark style="color:blue;"><code>decimals</code></mark></td><td>numeric</td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2611">☑️</span></td><td>the number of decimals that are included in the returned text</td><td></td></tr><tr><td><mark style="color:blue;"><code>grouping</code></mark></td><td>yes/no</td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2611">☑️</span></td><td>a boolean that indicates if large numbers are grouped (a separator is used)</td><td></td></tr><tr><td><mark style="color:blue;"><code>language</code></mark></td><td>language keyword</td><td align="center"></td><td>this parameter is used to specify the number representation according to the specified language/culture.</td><td></td></tr></tbody></table>

{% hint style="warning" %}
If the `language` parameter is not specified or contains an unknown value, then the default portal language is used to format the number.
{% endhint %}
