DataFormat.Error: We couldn't convert to Logical
By Tahir Nas · Examples run in our simulator · Updated
DataFormat.Error: We couldn't convert to Logical.
Text was converted to true/false but isn't one of the values M understands. Logical.FromText accepts only "true" and "false" (any case), so Yes/No, Y/N or 1/0 fail.
Common causes
- Changing a Yes/No column to the True/False type.
- Survey exports that use Y, N or blank.
- Numbers stored as text such as "1" and "0".
How to fix it
- Map values explicitly: if Text.Upper([Active]) = "YES" then true else false.
- Use a mapping table for many spellings.
- Keep the raw column and add a typed logical column, so unexpected values are visible.
Find the step that fails
- Open the query in the Power Query editor (Excel: Data → Queries & Connections → Edit; Power BI Desktop: Transform data).
- Click the steps in Applied Steps from the top. The first step that shows the error is where it starts; later steps only repeat it.
- Read that step's formula in the formula bar (View → Formula Bar if it's hidden) and compare it with the columns and values the previous step produced.
Minimal example
Raises the error:
Logical.FromText("Yes")Fixed:
Text.Upper("Yes") = "YES"Both snippets are run by the Power Query Exercises simulator on every build: the first must raise DataFormat.Error, the second must run.