Smart Systems for Home

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

Power Query Logical.ToText: Step-by-Step Guide

· 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

Logical.ToText converts a logical (true/false) value into the text "true" or "false" in Power Query. You use it inside a custom column or a step formula when a downstream tool needs text rather than a Boolean, for example when concatenating a flag into a label or exporting to a system that rejects Boolean types. The function takes one argument, the logical value, and returns a text value. It is case-sensitive in output: it always returns lowercase "true" or "false".

What You'll Need

  • Power Query available in Excel (Data > Get Data), Power BI Desktop, or Power Query Online.
  • A query with at least one column that contains logical values (true/false), or a formula that produces a logical result.
  • Basic familiarity with the Power Query Editor and the formula bar or Advanced Editor.

Step-by-Step

  1. Open the Power Query Editor. In Excel, select a cell in your data and go to Data > Get Data > From Table/Range, or open an existing query via Data > Queries & Connections. In Power BI Desktop, use Home > Transform data. Menu labels can differ slightly by version, device, or region.
  2. Locate the column that holds logical values. If the column header shows an ABC/123 icon rather than a true/false icon, the column may already be typed as text or number. You can still apply the function to a logical expression, but the input must actually be logical.
  3. Add a custom column. Go to Add Column > Custom Column. In the dialog, give the new column a name, for example StatusText.
  4. Enter the formula. In the Custom Column formula box, type a formula that passes a logical value to Logical.ToText. For a column named IsActive, the formula is: Logical.ToText([IsActive]). If the column is not yet logical, convert it first or wrap a comparison, for example Logical.ToText([Score] > 50).
  5. Click OK. Power Query adds the new column and shows "true" or "false" as text. The column icon should indicate a text type (ABC).
  6. Verify the output type. If the new column is not typed as text, select the column and use Transform > Data Type > Text. This ensures later steps treat it as text, not as a logical value that happens to look like text.
  7. Apply the change. Select Home > Close & Load (Excel) or Home > Close & Apply (Power BI) to load the result.

If you prefer to edit the M code directly, open Advanced Editor and add a step such as AddedStatusText = Table.AddColumn(PreviousStep, "StatusText", each Logical.ToText([IsActive]), type text). This is the same operation the Custom Column dialog builds.

Common Mistakes

  • Passing text that looks like a Boolean. Logical.ToText("true") fails because the argument must be a logical value, not a string. Convert the string first with Logical.FromText if needed.
  • Passing a number. Logical.ToText(1) does not work; use a comparison such as .
  • Forgetting the column reference brackets. In a custom column, column names must be in square brackets, for example [IsActive], not just IsActive.
  • Assuming the output is capitalized. The function returns lowercase "true" and "false". If you need "True" or "Yes", wrap it with Text.Proper or a conditional expression.
  • Leaving the result typed as any. Without an explicit type, later steps may treat the value inconsistently. Set the type to text.
  • Using it on a column that contains nulls. A null logical value produces an error; handle nulls with if [IsActive] = null then null else Logical.ToText([IsActive]).

Tips

  • Use Logical.ToText when you need a stable text label for exports, merges, or concatenation. For display only, you can leave the Boolean as is.
  • If you need custom labels such as "Active" and "Inactive", use a conditional column instead of Logical.ToText, for example if [IsActive] then "Active" else "Inactive".
  • Combine with Text.Combine or the ampersand operator to build readable strings: "User is " & Logical.ToText([IsActive]).
  • Keep the original logical column if other steps depend on it; the new text column is a separate field.
  • When performance matters, avoid converting large columns unnecessarily; apply the function only where the text output is actually required.

Troubleshooting

If the formula returns an error, check the argument type first. The most common cause is passing text or a number instead of a logical value. Use the column's type icon to confirm it is logical. If the column contains errors or nulls, handle them before calling the function.

If the function name is not recognized, confirm you are in Power Query, not a DAX formula bar. Logical.ToText is an M function and works in the Power Query Editor, not in Power Pivot or a worksheet formula.

If the output looks correct but later steps treat it as Boolean, set the column data type to Text explicitly. In the Applied Steps list, check that the type change step appears after the custom column step.

If the query fails to refresh after loading, review the step that references the column. A renamed or removed source column breaks the formula. Update the column name in the formula or re-add the step.

If you are unsure whether the source column is logical, add a temporary custom column with Value.Type([IsActive]) to see the actual type, then remove it.

Frequently Asked Questions

What does Logical.ToText return?

It returns the text "true" or "false" for a logical input. The output is always lowercase.

Can I convert text back to logical?

Yes. Use Logical.FromText on "true" or "false" to get a logical value. Other strings cause an error.

Does Logical.ToText work on a column with nulls?

No. A null argument produces an error. Wrap the call in a conditional to handle nulls.

Is Logical.ToText available in Power BI and Excel?

Yes. It is part of the Power Query M language and works in Excel, Power BI Desktop, and Power Query Online.

Why do I get an error when I pass a number?

The function requires a logical value. Convert the number with a comparison, for example , before calling Logical.ToText.

Can I change the output to "Yes" or "No"?

Not with Logical.ToText alone. Use a conditional column or an if expression to map true and false to custom labels.