# Power Automate: Convert Text to a Number

> For the full documentation index, see https://250highstreet.com/llms.txt

> Convert text to a number in Power Automate with int() and float(). Fixes for empty values, commas, currency signs and decimals, with working expressions.

Use int() for whole numbers and float() for numbers with decimals. Both take text and return a number you can add, compare or send to a number column.

## What is the syntax of int() and float()?

Each function takes one text value. int('42') returns the number 42. float('3.14') returns the number 3.14.

Add the expression in a Compose action. To use a column value, write int(triggerOutputs()?\['body/Quantity'\]). Text from Forms, email and Excel often needs this step.

## Why does int() fail on a value such as 1.5?

int() accepts whole numbers only. int('1.5') returns an error, because the text has a decimal point.

Use float('1.5') instead. To get a whole number from a decimal, round first: int(formatNumber(float('1.5'), '0')). The format '0' rounds to the nearest whole number and returns text, which int() then converts.

## How do you convert text that has commas or a currency sign?

Remove the extra characters with [replace()](/guides/power-automate-replace-text-replace-function/) first: float(replace(replace('\$1,250.75', '\$', ''), ',', '')) returns 1250.75.

float() also takes a second value for the culture. float('1.250,75', 'de-DE') reads the German format and returns 1250.75. Use this when the source uses a comma as the decimal mark.

## Why does the conversion fail on an empty value?

An empty string is not a number. int('') returns an error. A blank SharePoint column often returns null, which also fails.

Give the function a fallback: int(coalesce(triggerOutputs()?\['body/Quantity'\], '0')). Or test first: if(empty(variables('text')), 0, int(variables('text'))). For the related null error, see [expected String but got Null](/guides/power-automate-invalid-type-expected-string-but-got-null/).

## How do you convert a number back to text?

Use string(). string(42) returns the text 42. Use it when an action needs text, such as the body of an email.

To control the look of the result, use formatNumber(). formatNumber(1250.5, 'N2') returns 1,250.50. See [format a number as currency](/guides/power-automate-format-number-as-currency/) for more patterns.

## Why do two numbers compare in the wrong order?

A Condition compares text character by character when both values are text. The text 10 is less than the text 9, because 1 comes before 9.

Convert both values first: int(variables('a')) is greater than int(variables('b')). Check that the Condition shows the converted expressions, not the original dynamic content. Convert before you [sort an array](/guides/power-automate-sort-array/) of text numbers for the same reason.

## FAQ

### What does int() do with a very large number?

Very large whole numbers can fail. Use float() for them, and expect some rounding.

### Do I need to convert a number column from SharePoint?

No. A Number column already returns a number. Convert only when the value arrives as text, for example from a Single line of text column, Forms or an email.

### Can I convert a true or false text to a Yes/No value?

Yes. Use bool('true') to get a Yes/No value. The function also accepts the numbers 1 and 0.

## Sources

- [Reference guide to workflow expression functions in Azure Logic Apps and Power Automate](https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference)
- [Power Automate: float function](https://manueltgomes.com/reference/powerautomate-function-reference/float-function/)

## Related guides

- [Power Automate: Replace Text With replace()](/guides/power-automate-replace-text-replace-function/)
- [Fix "Invalid type. Expected String but got Null" in Power Automate](/guides/power-automate-invalid-type-expected-string-but-got-null/)
- [Power Automate: Format a Number as Currency With formatNumber()](/guides/power-automate-format-number-as-currency/)
- [Power Automate: Sort an Array With sort() and reverse()](/guides/power-automate-sort-array/)

Source: https://250highstreet.com/guides/power-automate-convert-text-to-number-int-float/
