Fix the Null-to-Type-Logical Error in Power BI
The [Expression.Error] We cannot convert the value null to type Logical message means that a Power Query expression expected true or false, but received null instead. It usually happens when a source field is blank and is used in an if condition, filter, comparison, or Boolean calculation. The fix is to find the first failing Applied Step and decide what a missing value should mean for that particular field.
Use this table to match the symptom to the right kind of repair.
| Symptom | Likely Cause | Appropriate Fix |
|---|---|---|
An if expression fails when a number is missing |
A comparison such as [Cost] > 0 returns null when Cost is null |
Add an explicit null rule, filter the row, or convert null to a permitted value |
| Filtering by a True/False field fails | The filter condition receives null rather than true or false |
Filter for explicit true values |
| The query preview looks fine but loading fails | A later refresh evaluates rows that the preview did not expose | Check every Applied Step, then use Close and Apply to validate the full query |
The message begins with OLE DB or ODBC error: [Expression.Error] |
The Power Query error is being wrapped by the connector or model load process | Fix the underlying Power Query expression |
| The error says “null to type Record” instead | A connector expected a record, not a Boolean value | Diagnose the connector call separately; this is not the same error |
What the Null-to-Logical Error Means
In Power Query M, a logical value is either true or false. null means that no value is present. It is not automatically treated as false, zero, an empty string, or “not applicable.”
For example, this expression works when Cost of goods contains a number:
if [Cost of goods] > 0 then [Product] & [Category] else null
When [Cost of goods] is null, the comparison [Cost of goods] > 0 produces null rather than true or false. The comparison produces null, while the if statement requires a logical result.
This is why the error often appears in expressions involving:
if ... then ... else- Numeric comparisons such as
>,<, or= - Filters using a nullable True/False column
- Custom columns used later in merges, joins, or conditional transformations
- Combined conditions using
andoror
The source data may be valid in the sense that a field is allowed to be missing. The failure is that the query has not defined what to do when it is missing.
How to Fix the Null-to-Logical Error
Step 1: Find the First Failing Applied Step
- In Power BI Desktop, select Home > Transform data to open Power Query Editor.
- Select the query that fails.
- In the Query Settings pane, click the items under Applied Steps one at a time, starting near the source step.
- Look for the first step that shows an error, a blank preview, or an error value in a column.
- Check the formula bar or open the custom-column, filter, merge, or type-change step that introduced the failure.
Do not assume the last step is the problem. A custom column can create a null-based error that becomes visible only when a later merge, filter, or model-load step evaluates it.
Look especially for a nullable source field used in a condition. A new row with an unfilled field can introduce this problem even when nobody has edited the report itself.
Step 2: Identify the Missing Field and Its Intended Meaning
Before changing code, decide what a null value means in the business data.
A missing cost might mean:
- The row is incomplete and should not load.
- The cost is unknown, but the row should still load.
- The missing value should be treated as zero.
- The field is optional, and the result should remain null.
Fix the business meaning of missing input instead of forcing all nulls into a Boolean.
For example, treating a missing sales amount as zero may be reasonable in one dataset but misleading in another. In contrast, a missing “Active” flag usually should not be treated as active.
Step 3: Add the Appropriate Null Rule
Choose one repair based on the meaning of the missing value.
If a row without a required value should be excluded, filter it before the calculation that needs the value. For a required numeric cost field, add a filtering step before the custom column:
= Table.SelectRows(#"Changed Type", each [Cost of goods] <> null)
Then make the custom-column step use the filtered step as its input. This prevents the calculation from ever receiving a null cost.
If null costs are valid and should produce a concatenated reference, explicitly include the null case in the condition:
= Table.AddColumn(#"Changed Type", "ConCat Ref", each if [Cost of goods] > 0 or [Cost of goods] = null then [Product]&[Category] else null)
This expression creates ConCat Ref when the cost is positive or missing, and returns null for zero or negative costs.
If the business rule genuinely says that a missing numeric value is zero, normalize it before comparing it:
= Table.AddColumn(#"Changed Type", "ConCat Ref", each
if (if [Cost of goods] = null then 0 else [Cost of goods]) > 0
then [Product] & [Category]
else null)
Use this pattern only when zero is a truthful replacement for an unknown or omitted value.
For a nullable Boolean field, compare it explicitly rather than using the column directly as the filter condition. This keeps only rows whose value is actually true:
= Table.SelectRows(#"Previous Step", each [IsActive] = true)
A null IsActive value will not be treated as true, and the filter receives a proper logical result for every row.
Step 4: Load the Query and Confirm the Repair
- Return to the final Applied Step and confirm the preview shows the expected rows and columns.
- Check that rows with missing values are being filtered, preserved, or normalized according to the rule you chose.
- Select Close and Apply to load the query into the Power BI model.
- If loading fails, return to Power Query and inspect the earlier Applied Steps again. The visible error may be triggered by a calculation that occurred before the final step.
- Save the report after the model loads successfully.
The error can first appear after selecting Close and Apply, even when the faulty custom column or filter was created earlier. The query preview may not force every row through every downstream operation, while the model load does.
Choosing Between Null, Zero, Empty Text, and False
null is not the same thing as zero, an empty text value, or false. Each represents a different statement about the data:
null: no value is known or supplied.0: the value is known and is zero."": the value is text and happens to be empty.false: the condition is known and is not true.
Use null when a result should remain unknown or not applicable. Use zero only when a missing numeric value should be counted as zero. Use an empty string only for a text field where blank text is meaningful. Use false only when a missing flag should deliberately be treated as “No.”
A quick way to avoid this error is to write null handling before the comparison:
if [Amount] = null then null
else if [Amount] > 0 then "Positive"
else "Not positive"
This structure is especially useful for more complicated conditions because Power Query never has to evaluate [Amount] > 0 when Amount is missing.
Why the Error Can Appear Only During Close and Apply
Power Query can show a usable preview even when some rows outside that preview would fail. It can also defer evaluation until a later transformation, merge, data-model load, or refresh operation needs the affected value.
That is why an earlier custom column may look harmless until you select Close and Apply. The model load can evaluate data that was not visibly failing in the editor.
If the message begins with something like:
OLE DB or ODBC error: [Expression.Error] We cannot convert the value null to type Logical
the important part is still [Expression.Error]. The OLE DB or ODBC text is usually the outer error reported while Power BI loads the query result. Fix the M expression that is producing null where Power Query expects true or false.
Power Apps Dataflows, Lakehouses, and Connector Errors
The same underlying issue can occur in Power Apps dataflows, Fabric dataflows, and Lakehouse-related Power Query transformations. If the message includes [Expression.Error] and says “type Logical,” inspect the query transformation that creates a condition, filter, or custom column.
The interface may differ, but the repair is the same:
- Find the transformation using a nullable field.
- Decide what a missing value means.
- Filter, preserve, or normalize the null explicitly.
- Refresh or publish the transformed data again.
Do not apply a workaround intended for a different type error. For example, “We cannot convert the value null to type Record” means a connector or function expected a record structure. That is different from a logical-conversion error, where a condition expected only true or false.
Verify the Fix and Prevent It From Returning
After correcting the expression, verify both the query and the source data.
Use this short checklist:
- The first failing Applied Step no longer contains errors.
- Nullable fields are not used directly as
ifconditions or Boolean filters. - Required source fields are filtered or validated before calculations rely on them.
- Optional source fields have an explicit null rule.
- Close and Apply completes without a model-load error.
- A refresh succeeds using the current source data.
Preventing recurrence usually starts in the original data source. If a field is required for a calculation, make it required in the form, spreadsheet, database process, or upstream dataflow that creates the data. If null values are valid, document the expected behavior and keep that rule in the Power Query transformation rather than relying on implicit conversion.
Frequently Asked Questions
How Do I Convert a Null Value to Zero in Power Query?
Use an explicit condition that replaces null before the numeric comparison. For a field named Amount, return zero only when zero is the correct business value:
if [Amount] = null then 0 else [Amount]
You can place that expression inside a custom column, or use it before a comparison such as > 0.
What Is a Logical Error Example in Power Query?
A common example is using a nullable numeric column as an if condition through a comparison:
if [Cost of goods] > 0 then "Include" else "Exclude"
When Cost of goods is null, the comparison cannot produce true or false. Add a null branch before the comparison or decide how a null cost should be handled.
What Does “Null Value Is Eliminated by an Aggregate” Mean?
“Null value is eliminated by an aggregate” means an aggregate operation, such as a sum or average, ignored null values while calculating a result. It is different from “cannot convert the value null to type Logical,” which occurs when a condition needs true or false.
Check whether ignored missing values are acceptable for the calculation. If they are not, replace or handle nulls before the aggregation using a rule that matches the meaning of the data.
Why Does a Boolean Column Cause This Error When Most Rows Are Valid?
A Boolean column can contain null values even if nearly every row contains true or false. A filter or conditional statement that uses the field directly fails when it reaches the null row.
Filter for an explicit true value instead:
each [IsActive] = true
This makes null values evaluate as “not selected” rather than trying to convert null into a logical value.
