> For the complete documentation index, see [llms.txt](https://docs.wem.io/platform/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wem.io/platform/wemreference/functions/text/formatnumber.md).

# 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](/platform/wemreference/sql-compatibility.md).
{% 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;

If decimals are part of the original value, and the number of allowed decimals in the formatting is less, there will be a standard **rounding** effect as well.&#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.7813, 2)`\
\=> `123456,78`  *(when the currentlanguage has the comma for decimal point)*

`FormatNumber(123456.789, 2, en_US)`\
\=> `123456.79 (rounding up)` &#x20;

`FormatNumber(123456.789, unknownnumber)`\
\=> `unknown` &#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.7813, 2, true)`\
\=> `123.456,78`  *(when the currentlanguage has the comma for decimal point)*

`FormatNumber(123456.789, 2, true, en_US)`\
\=> `123,456.79 (rounding up)`

`FormatNumber(12345.6789, 3, false)`\
\=> `12345.679 (rounding up)`

`FormatNumber(unknownnumber, unknownnumber, unknownboolean)`\
\=> `unknown`

</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 %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.wem.io/platform/wemreference/functions/text/formatnumber.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
