# Format Number In Power Automate

In this Power Automate tutorial, I will explain how to format number in Power Automate.

Microsoft provides a function in Power Automate called formatNumber() that you can use to format a number in Power Automate. Also, you can use the Format Number action in Power Automate.

I will also show you a few examples related to format number in Power Automate:

• How to format number as currency in Power Automate
• How to format number to leading zeros in Power Automate
• Working with Power Automate float decimal places expression
• Power Automate format number Hexa decimal expression
• Power Automate format number thousand separator
• Format number to percentage in Power Automate
• Power Automate Fixed Point decimal places
• Power Automate format number expression as exponential format

## Power Automate formatNumber() Function

formatnumber() Power Automate is a function that takes a number and formats it into the desired format, which can be a float, currency, percentage or another type of data.

Below is the syntax for the Power Automate format number:

``formatNumber(number, 'format', 'locale')``

Where,

• Number: Provide the number that you want to format
• â€˜formatâ€™: The number will get formatted
• Locale: Provide the locale while formatting the number to any different data type [Optional]

Example:

``formatNumber([7895], 'C0')                                    // Output - \$7895``

## How to Use Power Automate formatnumber Function

Let’s discuss some of the useful examples using Power Automate format number expression:

### Format Number as Currency in Power Automate

Here, I will explain how to work with Power Automate format number as currency.

To define the standard currency format, Power Automate format the number as currency with commas, i.e., ‘C’ format. To get the decimal places after the number, use ‘C’ followed by numbers.

‘C2’ represents the default format concerning ‘C’. Refer to the table below:

1. Open the Power Automate Home page, click on + Create -> Instant cloud flow. Give Flow name, and select trigger Manually trigger a flow -> Create.

• In the trigger, Click Add an input -> Select Number.

2. Now, add an ‘Initialize variable’ flow action and set properties like Name, Type, and Value.

``Value: formatNumber(triggerBody()['number'],'C0')``

3. In this step, add ‘Compose’ data operation to check the output received from the given expression.

4. Now, it is time to save and test the flow. Click on Save and Test -> Test Manually.

5. The outputs of the compose data operation will return the formatted number as currency, as shown below:

This is how to get the formatted number as currency with commas inside a Power Automate flow.

### Format Number With Leading Zeros in Power Automate

Next, we will see how to work with Power Putomate add leading zeros.

In Power Automate, this can be done by providing a standard ‘D‘ format in formatNumber expression. In the expression, ‘D’ followed by the digit refers to the total number of digits consisting of a provided number.

The below-placed table below will show different formats of digit expression:

For that, follow the above-mentioned but only need to change the expression of formatNumber.

1. In the ‘Initialize variable’ flow action, provide details like Name, Type, and Value to convert the string to an integer.

``int(triggerBody()['number'])``

2. In the Inputs of compose flow action, add the below-given expression to add the leading zeros.

``formatNumber(variables('Digit'),'D3')``

3. The output displayed from the compose data operation will show the result below.

This way, we can achieve Power Automate format number leading zeros.

### How to Use Power Automate Float Decimal Places

To add decimal places for a number, use the format() number function using the standard ‘F‘ format inside a Power Automate flow.

In the expression, ‘F’ followed by the digit refers to the total number of decimals provided. In the formats, ‘F2’ is the default format that resembles the ‘F’ format.

1. Provide the formatNumber expression in the value section of the initialized variable.

``Value: formatNumber(triggerBody()['number'],'F2')``

2. The image below shows the decimal places output from the formatted number.

### Power Automate Format Number Thousand Separator

A user can format a number separated by commas and configure the number of decimal places using the formatNumber() expression with the standard ‘N‘ format.

The ‘N’ format is similar to the ‘F’ format. In the same way, ‘N’ is followed by a digit, which refers to the total number of decimals provided in it.

1. Give the expression for a thousand separator with commas in the value of an initialized variable.

``formatNumber(triggerBody()['number'],'N1')``

2. The returns of the formatted number expression will give the number with commas as shown below.

### How to Format Number to Percentage in Power Automate

We can use the standard ‘P‘ format with the Power Automate format number as a percentage.

Using this, the percentage will be multiplied by 100, and the output will be a string along with the percentage.

In the expression, ‘P’ followed by a digit refers to the number of decimals displayed that should be included in the format.

1. Add the below-placed percentage expression in the ‘Value’ parameter of an initialized variable.

``formatNumber(triggerBody()['number'],'P1')``

2. The returns of the formatNumber expression will be displayed in the outputs of compose.

This way, we can format numbers into percentages in Power Automate.

### How to Format Number to Hexadecimal in Power Automate

The hexadecimal format is the number system with a base value of ‘16‘, which includes numbers from (0-9) and digits from (A-F).

Examples:  7B316, 6F16.

In Power Automate, this format can be achieved using the formatNumber() expression with the standard format of ‘X‘. This format only works for the whole numbers.

1. In the ‘Initialize variable’ change the expression of formatNumber to hexadecimal format. Use the below expression placed in the code.

``formatNumber(triggerBody()['number'],'X')``

2. The hexadecimal format of the provided number will be displayed in the below screenshot.

This way, we can format a number to hexadecimal in Power Automate.

### Power Automate Fixed Point Decimal Places

Regardless of how many decimal places the provided number has, the formatted number will be presented in the Fixed-Point decimal places corresponding to the decimal we fixed in the formatNumber() expression.

If the provided number is a whole number, it will be added to that number by a fixed number of decimal places.

This can be done using the standard ‘F‘ format in the formatNumber() expression. The precision specifier will define the number of decimal places that should be displayed.

1. Add the ‘Initialize variable’ flow action and set the below details.

• Name: Enter a name for a variable.
• Type: Select a datatype from the drop-down.
• Value: Add the value as given in the code below.
``formatNumber(triggerBody()['number'],'F3')``

2. The compose flow action outputs will give the return value from the formatted number expression.

### How to Format Number as Exponent in Power Automate

Power Automate has a formatNumber() function that converts numbers into exponent form using the standard ‘E‘ format.

The exponential format is in the form of (E+n). There is always a dot after one digit. In the expression, ‘E’ followed by the number will define how many digits should be displayed after the dot. By default, it will take six digits after the dot.

1. Add the value of the initializing variable with the formatNumber expression that will convert the number into an exponential format.

``Value: formatNumber(triggerBody()['number'],'E')``

2. The outputs of the compose data operation will display the formatted number in exponential format, as shown below.

This way, we can format a number as an exponent in Power Automate.

## Conclusion

I hope this article gave you an overall idea of how to work with format numbers in Power Automate. There are various examples, such as format number as currency in Power Automate, format number to leading zeros in Power Automate, and many more.

Some more articles you may also like: