Power Query Text.Format Function: Step-by-Step Guide
In this article
Power Query's Text.Format function (in M) builds a text string by inserting values into a template that contains placeholders. It is the M equivalent of string formatting: you write a template like "Order {0} shipped on {1}" and pass the values in a list, and Power Query returns the combined text. You do not need any add-in or special connector; Text.Format is available in the standard Power Query Editor in Excel, Power BI Desktop, and Dataflows, and you call it from the formula bar or the Advanced Editor.
What You'll Need
- Power Query Editor open on a query (Excel: Data > Get Data > Launch Power Query Editor; Power BI: Transform data).
- A query with at least one text, number, or date column you want to combine into a single string.
- Basic familiarity with the formula bar and the Advanced Editor, since Text.Format is written as an M expression rather than clicked through a dialog.
Menu labels and button names can differ slightly by version, app, or region, so treat the paths below as a guide and look for the closest match.
Step-by-Step
- Load the data you want to format. Connect to your source and make sure the columns you will reference are present. Rename columns to short, clear names (for example Customer, OrderID, ShipDate) using right-click > Rename, because you will type these names in the formula.
- Add a custom column. On the Home tab, click Add Column > Custom Column. In the dialog, give the new column a name such as Summary. Leave the formula box ready for the expression you will build in the next steps.
- Write the basic Text.Format pattern. In the formula box, type a template string with numbered placeholders in braces, then a comma, then a list of the values in the same order. For example:
Text.Format("Order {0} for {1}", {[OrderID], [Customer]}). The {0} is replaced by the first item in the list, {1} by the second, and so on. Click OK. - Check the result. The new column should show the combined text. If you see an error instead, open the step in the formula bar and confirm the placeholder numbers match the number of items in the list and that every column name exists in the current step.
- Format numbers and dates inside the template. Text.Format placeholders accept a format string after a colon, for example
Text.Format("Total: {0:N2}", {[Amount]})for two decimal places, orText.Format("Shipped: {0:yyyy-MM-dd}", {[ShipDate]})for an ISO-style date. The format codes follow the standard .NET-style patterns Power Query uses for numbers and dates. - Handle nulls before formatting. If a value can be null, the formatted text may show an error or an empty gap depending on the type. Wrap the value with a fallback, for example
Text.Format("Customer: {0}", {[Customer] ?? "Unknown"}), so the row still produces a readable string. - Convert the column type. The custom column is usually typed as text already, but if Power Query shows it as any, click the type icon in the column header and choose Text. This keeps later steps such as merging or loading predictable.
- Test edge cases. Filter or scroll to rows with blanks, very long values, and unusual characters. If a value contains braces, they are treated as literal text only when they are not part of a valid placeholder; to be safe, keep templates simple and avoid stray braces.
- Reuse the pattern elsewhere. Once the expression works, copy it into other custom columns or into a step in the Advanced Editor. You can also store the template in a parameter if you want to change the wording in one place.
- Apply and load. Click Home > Close & Load (or Close & Apply in Power BI) to send the formatted column to your worksheet or data model.
Common Mistakes
- Mismatched placeholder count. A template with {0} and {1} needs exactly two items in the list. Extra placeholders or missing values produce an error.
- Forgetting the list braces. The second argument must be a list, written with curly braces:
{[A], [B]}. Passing a single value without braces is a frequent cause of errors. - Using column names that no longer exist. If you rename or remove a column in an earlier step, the Text.Format expression breaks. Update the formula or rename the column back.
- Assuming Text.Format changes the data type. It returns text. If you need a number or date later, convert it back explicitly.
- Ignoring culture and locale. Number and date formats can render differently depending on the file's locale settings, so a format that looks right on one machine may differ on another.
Tips
- Keep templates short and readable; long templates are harder to debug when a placeholder fails.
- Use named steps in the Applied Steps list so you can click back and inspect the exact table Text.Format receives.
- For repeated wording, define the template once in a query parameter and reference it, rather than retyping the string in several custom columns.
- When combining many columns, build the list in the same order as the placeholders and add a comment in the Advanced Editor so the order is obvious later.
- Test with a small sample query before applying the pattern to a large table, so errors surface quickly.
Troubleshooting
If the custom column shows Error, click the error cell to read the message. A message about a token or a missing field usually means a column name is wrong or a placeholder number is out of range. A message about the argument type usually means the second argument is not a list; add the curly braces around the values.
If the output is blank where you expected text, check whether the source value is null and add a fallback with ??. If numbers or dates look wrong, confirm the format string after the colon matches the value type; a date format applied to a number will not produce the result you expect.
If the step worked before but fails after a source refresh, the source may have changed column names or added nulls. Open the step before the custom column and compare the column list. If the whole query fails to load, remove the custom column step temporarily to isolate whether Text.Format is the cause, then rebuild it one placeholder at a time.
If the formula bar will not accept the expression, check for missing commas or unbalanced quotes. Power Query is strict about syntax, and a single missing quote will stop the step from validating.
Frequently Asked Questions
What is the difference between Text.Format and Text.Combine?
Text.Combine joins a list of text values with a separator and does not use placeholders. Text.Format inserts values into a template, which is better when the wording around the values matters.
Can Text.Format format dates and numbers?
Yes. Add a colon and a format string inside the placeholder, such as {0:N2} for a number or {0:yyyy-MM-dd} for a date. The exact patterns follow the standard formatting rules Power Query uses.
Does Text.Format work in Excel Power Query and Power BI?
Yes. It is part of the M language used by both, so the same expression works in the Power Query Editor in Excel and in Power BI Desktop, subject to version differences in the editor interface.
Why does my Text.Format step return an error about a list?
The second argument must be a list in curly braces. If you passed a single column reference without braces, wrap the values in { } and separate multiple values with commas.
Can I use Text.Format to build a file path or URL?
Yes, it is commonly used for that. Build the template with placeholders for the variable parts and pass the values in a list. Check the result for invalid characters before using it in a file or web step.
Is Text.Format available in the Power Query user interface as a button?
No. It is written as an M expression in a custom column or the Advanced Editor. There is no dedicated dialog for it, so you type the formula directly.