Using Format Number in Power Automate

Power Automate, formerly Microsoft Flow, enables the automation of repetitive tasks through custom workflows. Among its key features is the formatNumber function, which allows for precise number formatting. In this blog post, we’ll demonstrate how to utilize the formatNumber function to format numerical values effectively within your workflows.

What is the Format Number Function?

The ‘formatNumber' function in Power Automate is used to format a number into a string representation based on a specified format. This function is particularly useful when you need to ensure numbers are displayed in a consistent and readable manner, such as formatting currency values, percentages, or adding leading zeros.

Syntax of the Format Number Function

formatNumber(number, format)

Where ‘number' is the numerical value you want to format, and format is the string that defines the formatting pattern.

Step-by-Step Guide to Using the Format Number Function in Power Automate

Step 1: Create New Flow

Go to Power Automate (flow.microsoft.com) and create a instant cloud flow with a manual trigger. After you have created a title select “Create” to begin building the flow.

Step 2: Initialize Variables

Add a new action, “Initialize variable”, to store the number you want to format
Set the name to ‘numberToFormat’, type to ‘Float’, and provide a sample value

Step 3: Format Number Function in Compose Action

Add a “Compose” action to use the ‘formatNumber’ function
Set the input to the following expression to format the number as percentage with two decimal places:

fomatNumber(variables('numberToFomat'), 'P2')

Step 4: Output the Result

Add a new action, “Compose”, to output the formatted number.
Set the input to the result of the previous “Compose” action.

Spread the word

Leave a Reply