Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel Power Query: Convert Numbers to Text

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To convert numbers to text in Excel Power Query, use the Text.From function in a custom column or the Data Type dropdown to set the column to Text. The quickest path is to select the column, go to Transform or Add Column, and choose Data Type > Text. This preserves the original values as text strings, which is useful when you need to concatenate numbers with text, keep leading zeros, or export to systems that expect text fields. Before you begin, ensure your data is loaded into Power Query (via Data > Get Data or an existing query).

What You'll Need

  • Microsoft Excel with Power Query (Excel 2016 or later, or Excel 2010/2013 with the Power Query add-in).
  • A dataset already imported into Power Query (from a table, range, CSV, or database).
  • Basic familiarity with the Power Query Editor interface: the ribbon, the Queries pane, and the Applied Steps list.

Step-by-Step

  1. Open the Power Query Editor. In Excel, select your data and go to Data > From Table/Range (or Get Data and choose your source). The Power Query Editor window opens.
  2. Locate the numeric column. In the editor, find the column containing the numbers you want to convert. The column header shows a data type icon (e.g., a 123 for whole number).
  3. Change the data type to Text. Click the data type icon in the column header, then select Text from the dropdown. Alternatively, select the column, go to the Transform tab, and click Data Type > Text. Power Query adds a step like Changed Type in the Applied Steps pane.
  4. Verify the conversion. The column values should now appear left-aligned (text is left-aligned by default) and the data type icon changes to ABC. Check a few rows to ensure no values were altered (e.g., leading zeros preserved if they existed).
  5. Use Text.From for custom columns (optional). If you need to convert numbers within a formula, go to Add Column > Custom Column. In the formula box, enter Text.From([YourColumnName]) and click OK. This creates a new text column without changing the original.
  6. Handle formatting (optional). If you need specific formatting (e.g., two decimal places), use Number.ToText([YourColumnName], "0.00") in a custom column. This converts the number to text with the specified format.
  7. Apply and close. Click Home > Close & Load to load the transformed data back into Excel as a table or connection. The column will now be text.

Common Mistakes

  • Changing data type in Excel instead of Power Query. If you convert numbers to text after loading, Power Query will still treat them as numbers on refresh. Always convert within the Power Query Editor.
  • Forgetting to check for errors. Converting a column with mixed types (e.g., numbers and text) may produce errors. Use Replace Errors or filter them out before conversion.
  • Losing leading zeros. If your numbers have leading zeros (e.g., "00123"), converting to text in Power Query preserves them only if they were already text. If they were numeric, leading zeros are lost. Use Text.PadStart to add them back.
  • Assuming Text.From works on nulls. Text.From returns null for null values. If you need an empty string, use if [Column] = null then "" else Text.From([Column]).
  • Not refreshing after changes. After modifying the query, click Refresh in Excel to see the updated data.

Tips

  • Use the UI for simple conversions. The Data Type dropdown is the fastest way for whole columns.
  • Combine with other transformations. Convert to text before merging columns or using text functions like Text.Combine.
  • Document your steps. Rename steps in the Applied Steps pane for clarity (right-click > Rename).
  • Test with a small sample. Before applying to the whole dataset, duplicate the query and test on a few rows to ensure the conversion behaves as expected.
  • Use Text.From for dynamic conversions. It's useful when the column name is dynamic or when you need to convert multiple columns in one custom column.

Troubleshooting

  • Column still shows numbers after conversion. Check the Applied Steps: ensure the Changed Type step is not followed by another step that redefines the type. Also, verify that the column is not being used in a calculation that forces numeric type.
  • Errors after conversion. Some values may not convert (e.g., "N/A"). Use Replace Errors with a default value, or filter out error rows before conversion.
  • Leading zeros missing. If the original data had leading zeros but was stored as numbers, they are lost. Use Text.PadStart(Text.From([Column]), 5, "0") to pad to a fixed length.
  • Conversion not applied on refresh. Ensure the query is loaded correctly and that you haven't manually changed the column type in Excel. Power Query overwrites manual changes on refresh.
  • Text.From returns error. Check that the column name is correct and that the value is not an error. Use try Text.From([Column]) otherwise null to handle errors gracefully.

Frequently Asked Questions

Can I convert numbers to text without losing leading zeros?

Yes, but only if the original values were stored as text. If they were numeric, leading zeros are already lost. Use Text.PadStart to add them back after conversion.

What is the difference between changing data type and using Text.From?

Changing the data type alters the column in place. Text.From creates a new column (in a custom column) and leaves the original unchanged, which is useful for preserving the numeric version.

Why does my converted text column still behave like a number in Excel?

Power Query loads the column as text, but Excel may interpret it as numbers if the values look numeric. To force text, prefix with an apostrophe or format the column as Text in Excel after loading.

Can I convert multiple columns at once?

Yes, select multiple columns (Ctrl+click headers), then change the data type to Text. All selected columns will be converted.

Does converting to text affect sorting or filtering?

Yes, text sorting is alphabetical (e.g., "10" comes before "2"), unlike numeric sorting. Be mindful if you rely on order.

What if I need to convert back to numbers later?

You can change the data type back to Whole Number or Decimal Number in Power Query. However, any non-numeric characters will cause errors.