How to Convert Float to Integer in Power Automate?

This Power Automate tutorial will show us how to convert float to integer in Power Automate with different examples.

Scenario:

I will show two examples of converting float to int using Power Automate.

In the first example, the flow will trigger manually, asking to enter a value in a textbox. If the user enters a float value like 16.233, it will use the int function and return an integer value of 16.

In the second example, we will see the dynamic approach, where the flow uses a manual trigger and gets all items from the SharePoint list. The Product Price column, which has a float value like 1495.23, converts to an integer value using the int function, returns the value as 1495, and updates the SharePoint list.

Convert float to integer in Power Automate

To achieve this, follow the below steps:

We will discuss converting a float to an integer value using Power Automate or Microsoft Flow.

Example-1: (Manual Approach)

Step-1:

  • Initially, log in to Power Automate flow using the credentials, and select +Create -> instant cloud flow.
  • Enter the flow name, Choose Manually trigger a flow, and click on the create option as highlighted below:
How to convert float to integer in Power Automate

Step-2:

Expand the Manually trigger action, and add a Number input to enter the number value in a float data type.

How to convert float to integer in Power Automate flow

Step-3:

Add a compose data operation, and pass the below expression to convert the float type value to an integer data type.

int(first(split(string(triggerBody()['number']),'.')))
convert float to integer in Power Automate flow

Step-4:

Save and Run the flow by selecting the run flow option. Enter the Float number value Here, I gave the input value as 16.233 and click the run flow option.

Power Automate convert float to integer

Once our flow ran successfully like below, we can see it will use the int function, convert the float value to an integer value, and return the value as 16 in the output of the compose data operation.

Power Automate convert float to integer value

This is how to convert a float to an integer value using Power Automate Flow.

Example-2: (Dynamic Approach)

In this example, we are going to use the below SharePoint list called Products consisting of,

  • ProductName – default Title column
  • ProductQuantity – Number column
  • ProductPrice – Number column (Float Values)
Example to convert float to integer in Power Automate flow

Step-1:

  • Login to Power Automate and create an instant cloud flow. Select + new step and choose the Get items action from the action triggers.
  • Configure the SharePoint site address and List Name. Here my List Name is Products.
Example to convert float to integer in Power Automate

Step-2:

Add an apply to each control and pass the dynamic content values to loop through all the items presented in the SharePoint list.

convert float to integer in Power Automate

Add +new step and choose the select data operation in the from section, pass the dynamic content values, and in the map field, pass the ProductPrice value.

convert float to integer in the Power Automate flow

Add a compose data operation, and pass the below expression to convert the float type value to an integer data type for the ProductPrice column.

int(first(split(string(items('Apply_to_each')?['ProductPrice']),'.')))
convert float to integer in Power Automate example

Select the +New step and add the Updated item action from action triggers and provide the below-required fields:

  • Site Address – Choose the SharePoint site address
  • List Name – Select the List Name
  • ID – Select ID from the dynamic content value.
  • Title – Pass Title value from dynamic content.
  • ProductPrice – Choose the Output of the compose action from the dynamic content value to update as an integer value.
Example to convert float to integer in the Power Automate flow

Step-3:

Save and Run the flow by selecting the run flow option. It retrieves all the items from the SharePoint list, loops through the values, and converts the float to int using the int function. Once our flow ran successfully like below:

Power Automate convert float value to integer value

The ProductPrice column has been updated to the integer data type value from the float type value.

convert float value to integer value in Power Automate flow

This is how to dynamically convert a float to an integer value using Power Automate Flow.

In this Power Automate tutorial, we saw how to convert float to integer in Power Automate with different examples.

You may also like:

>