Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
fzhang
Regular Visitor

[Expression.Error] We cannot convert the value null to type Logical.

Hi all, 

 

In my query, the following step is causing the error: [Expression.Error] We cannot convert the value null to type Logical.

 

here's M code

Table.FromRecords(Table.TransformRows(#"Expanded AccountXRef", (Row) => if Row[Charge To Home BU] then Record.TransformFields(Row, {
{"Charge To BU Number", each Row[Home BU Number]},
{"Charge To BU Name", each Row[Home BU Name]},
{"Charge To BU Type", each Row[Home BU Type]},
{"Charge To Division", each Row[Home Division]},
{"Charge To HRBP", each Row[Home HRBP]},
{"Charge To Director/Manager", each Row[#"Home Director/Manager"]},
{"Charge To Officer", each Row[Home Officer]},
{"Charge To EC Member", each Row[Home EC Member]}
}) else Row), Value.Type(#"Expanded AccountXRef"))

 

I have checked all the columns on the table and don't see any nulls. Can someone see what the issue is?

 

Thanks!

2 ACCEPTED SOLUTIONS
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

This part needs to be made conditional

if Row[Charge To Home BU]

This needs a conditional operator say

if Row[Charge To Home BU] <> null 

View solution in original post

There's a nifty null coalesce operator ?? now. This allows for handling null checks compactly.

if Row[Charge To Home BU] ?? false then ...

This is a shortcut for

if (if Row[Charge To Home BU] = null then false else Row[Charge To Home BU]) then ...

 

The operator is documented here (scroll all the way down to the end):
https://docs.microsoft.com/en-us/powerquery-m/m-spec-operators

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @fzhang ,

 

Could you tell me if your problem has been solved?

Both @Vijay_A_Verma  and @AlexisOlson 's suggestions are good.

If you are still confused about it, please provide me with more details about your problem. For example, provide some screenshots.

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

This part needs to be made conditional

if Row[Charge To Home BU]

This needs a conditional operator say

if Row[Charge To Home BU] <> null 

There's a nifty null coalesce operator ?? now. This allows for handling null checks compactly.

if Row[Charge To Home BU] ?? false then ...

This is a shortcut for

if (if Row[Charge To Home BU] = null then false else Row[Charge To Home BU]) then ...

 

The operator is documented here (scroll all the way down to the end):
https://docs.microsoft.com/en-us/powerquery-m/m-spec-operators

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.