Number.FromText in Power Query: How to Convert Text
In this article
Number.FromText converts a text value into a numeric value in Power Query, so "1,234.50" becomes the number 1234.5 that you can sum, sort or filter. You need Power Query available in your host app (Excel, Power BI Desktop, or a Power BI dataflow) and a column that actually contains the text you want converted. If the text is not recognisable as a number in the culture you specify, the function returns an error rather than a zero, which is why the second, optional argument matters so much.
What You'll Need
- Excel with Power Query (Windows or Mac), Power BI Desktop, or another host that includes Power Query. The menu labels can differ slightly by version, edition and region.
- A query that already loads your source table, and a column containing numbers stored as text.
- Basic familiarity with the Power Query Editor window: the ribbon, the Queries pane on the left, and the formula bar.
- A decision about how your numbers are formatted, meaning which decimal separator and thousands separator the text uses. This determines the culture argument you pass.
Step-by-Step
- Load the data into Power Query. Select a cell in your table, then use the Data tab and the From Table/Range command in Excel, or Get Data in Power BI Desktop. In Excel, make sure the range has proper headers before you load it, because Power Query uses the first row as column names by default.
- Confirm the column is text. Look at the type icon to the left of the column header. If it already shows a number type, you do not need Number.FromText at all; converting a number to a number is redundant and can mask other problems. If the icon shows ABC or a mixed type, continue.
- Decide whether a simple type change is enough. Right-click the column header, choose Change Type, and pick Decimal Number or Whole Number. Power Query will insert a type conversion step for you. This is the normal route and is what most people need. Use the function directly when you want explicit control over culture, error handling, or when you are writing custom column logic.
- Add a custom column. On the Add Column tab, click Custom Column. Give it a name such as Converted, then in the formula box enter the call. The syntax is Number.FromText(text as nullable text, optional culture as nullable text). For a column named Amount the formula is: Number.FromText([Amount]). Leave the culture argument out and Power Query uses the culture of your file or model.
- Set the culture when your separators differ from the file's default. Supply a culture code as the second argument, for example Number.FromText([Amount], "en-US") for text using a comma as thousands separator and a period as decimal point, or Number.FromText([Amount], "de-DE") for text using a period as thousands separator and a comma as decimal point. The culture code changes how dots, commas and currency symbols are interpreted, not just the display.
- Press OK and inspect the new column. Look for the green type icon and for any cells showing Error. Click a cell to see the raw text in the formula bar, then check the step in the Applied Steps list to confirm the transformation was applied to all rows rather than a filtered selection.
- Change the column type to a number. The custom column may come in as any type. Right-click its header, choose Change Type, and select Decimal Number or Whole Number so sorting, aggregation and relationships behave correctly downstream. This step is often forgotten and causes confusing results in pivots and visuals.
- Remove or keep the original column. Right-click the original text column header and choose Remove, or keep it for auditing and hide it later. Removing it is cleaner, but keeping it makes it easier to spot the rows that failed.
- Close and load. Use Home and Close & Load in Excel, or Home and Close & Apply in Power BI Desktop. The query then refreshes with the numeric column in place.
Common Mistakes
The most frequent mistake is the wrong culture code. Text like "1.234,56" read as en-US gives a completely different number than the same text read as de-DE, and often no error appears at all, so the result is silently wrong. Always check a couple of rows by eye after choosing a culture.
Another common problem is trailing spaces, non-breaking spaces and other invisible characters. Power Query trims some of these during a type change but not always when calling the function directly. Clean the text first with Text.Trim, and if non-breaking spaces are present, replace them using Text.Replace with the character code 160.
Leaving the column as text after conversion is also common. A custom column created with a function call frequently needs an explicit type change before aggregation works. Similarly, people convert values that were already numbers, which does nothing useful, and people expect the function to strip currency symbols in every case. Currency symbols are recognised only when they match the culture supplied; otherwise the conversion errors.
Finally, matching on a filtered subset of rows and then applying the conversion makes it look like the step works while the filtered-out rows are never processed. Check the Applied Steps panel for filter steps that were inserted above the conversion.
Tips
Wrap the call in a try expression to keep one bad row from breaking the whole refresh. The pattern try Number.FromText([Amount]) otherwise null returns null for failures while leaving good values alone, and you can add a second column using try ... otherwise "failed" to flag which rows need attention.
Use Table.TransformColumnTypes with a culture argument on the whole column as an alternative to a custom column. This keeps the step compact and applies the same culture consistently. If you have many columns with mixed formats, build a small culture-parameterised query function and invoke it on each column, so the logic is written once.
Keep separator decisions in one place. If you change the culture argument in several steps and later discover one is wrong, you have to hunt it down. A single parameter query holding the culture code makes that a one-field edit. Test with a sample that includes a thousands separator, a decimal fraction, a negative value in parentheses if your source uses that style, and a deliberately invalid value such as "n/a".
Troubleshooting
If the column shows Error for every row, the culture is probably wrong or the text contains letters, symbols or spaces the culture does not accept. Click a failing cell, read the exact string, and test it in the formula bar with the culture you chose. Swap the culture code and see whether the error clears.
If the column shows errors for only some rows, sort the column to bring errors together and inspect those specific strings. Common culprits are nulls, empty strings, dashes used for missing data, and numbers pasted with a leading apostrophe or stray quote marks. Handle them with a conditional step that returns null when the trimmed text is empty.
If the numbers look wrong rather than erroring, suspect culture and separator confusion first. A value of 1234 that should be 1.234 is a decimal separator being read as a thousands separator. Check the culture argument against the source format, and remember that changing the culture later requires editing the step, not just the column type.
If the conversion step appears but the output never changes, look for a later step that changes the type back to text, or for a filter that removes the converted rows. Also confirm you refreshed the query, since an unrefreshed preview can show stale results. If you still cannot isolate the problem, remove all steps after the conversion and add them back one at a time to find the one that breaks it.
Frequently Asked Questions
What is the difference between Number.FromText and changing the column type?
Changing the column type uses the same underlying conversion but is applied to the whole column in one step, using the file or model culture. Calling Number.FromText explicitly lets you pass a different culture and lets you wrap the call in try or otherwise for per-row error handling.
Does Number.FromText handle percentages and currency?
It recognises a percent sign only when the culture argument matches that convention, returning the decimal fraction. Currency symbols are recognised when they belong to the supplied culture. For mixed or unusual formats, strip the symbol with Text.Replace first and convert the remaining text.
Why does my result come back as null instead of a number?
If you used try ... otherwise null, the function failed and the null is your fallback, not a successful conversion. Remove the fallback temporarily to see the actual error, then fix the input text or the culture.
Can I use the function on a column that is already numeric?
It is unnecessary. The column may error because a native number is not text. Use the function only on columns whose type is text or any.
Which culture should I use for values like 1.234,56?
A European culture that uses a period for thousands and a comma for decimals, such as de-DE or nl-NL, depending on your source. If in doubt, convert a few known rows and compare them with the source values manually.
Does the conversion change on refresh?
Yes, the function runs every time the query refreshes, so any new text values are converted again with the same culture and error-handling logic. That is why consistent culture settings matter for automated refreshes.