How to Convert String to Float in Power Automate?

Do you need to convert a string to float in Power Automate? Then, this Power Automate tutorial will help you to know how to convert String to Float in Power Automate.

Scenario:

Sometimes user enters a float number value in a string data type; the Power Automate flow is considered a text value and not a float number value. In those cases, we must convert the string value to a float value and use it in our flows.

For example:

To perform a multiplication with two float values, we require two input values with the number data type.

So the user enters the first input value float number is 2.34 with the text data type and the second input value is 4.34 with the number data type. While performing the multiplication, the flow fails.

To overcome this, we have to convert the first input float value from the text data type to a Float Number value of the Number data type.

Then, we will use the multiplication operation with the two float input values. So, the flow will execute without any errors and display the output value as expected.

Convert String to Float in Power Automate

Let us see how to convert a string to a float number in Power Automate Flow,

1. Create an instant cloud flow; in the trigger action, add two inputs. The first input value is the text data type, and the second input value is the number data type.

How to Convert String to Float in Power Automate

2. We will use the float() function inside the flow to convert the String to a Float value.

See also  Microsoft Power BI KPI Visual - How to use

Add a compose data operation from the action triggers and pass the below expression, which converts the string value to float value.

float(triggerBody()['text'])

Where,

  • float – function name
  • triggerBody()[‘text’] – first input value
Convert String to Float in Power Automate flow

3. Now we will perform a multiplication with the two float number values.,

  • First input value – Converted float value text type to float value number type
  • Second input value – Directly passed float number value.

Select the compose data operation and pass the below expression, which performs the multiplication of two float values with a number data type.

mul(outputs('Compose'),triggerBody()['number'])

Where,

  • mul – function name
  • outputs(‘Compose’) – first input value (converted float value from text data type to float value number data type)
  • triggerBody()[‘number’] – second input value
Convert String to Float in Power Automate

4. Save the flow; Enter the two input values and click on the Run flow option.

power automate convert string to float

Once the flow runs successfully, we can see the flow performs a multiplication with the passed input float values and displays the output value as expected.

Example to Convert String to Float in Power Automate

This is how to convert a String to a Float Number in Power Automate Flow.

Conclusion

So, I hope you know why we need to convert a string value to a float number in Power Automate. I have also shown you an example of converting the string value to a float number by using the float() function in Power Automate.

You may like the following Power Automate tutorials:

>