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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Dunner2020
Post Prodigy
Post Prodigy

We cannot convert the value null to type Logical.

Hi there,

 

I am trying to create a conditional column based on another column. When I created a conditional column, I got an error "Expression. Error: We cannot convert the value null to type Logical". I am not sure where am I making the mistake. Below is the description of the columns:

 

First I created a column in power query which looks like as follow:

Customer Notification (days) =

if [InterruptionType] ="1" then null else
if Date.Year([#"Cancelled Date (NZST)"]) = 1900 and [InterruptionType] = "2" then List.Max({[#"Notice to Retail Consumer (days)"], [#"Notice to Direct Bill Consumer (days)"]})
else
if Date.Year([#"Cancelled Date (NZST)"]) = 1900 and [InterruptionType] = "3" and Date.Year([#"Notified Interruption Date Time (NZST)"]) <> 1900 then List.Max({[#"Notice to Retail Consumer (days)"], [#"Notice to Direct Bill Consumer (days)"]}) else null

 

and it looks like as follow:

leo_89_0-1622148468868.png

 

Then I created a conditional column using the following logic:

 

leo_89_1-1622148561744.png

However, it throws error of "Expression. Error: We cannot convert the value null to type Logical.

leo_89_2-1622148621241.png

Could anyone help me where I made the mistake?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Dunner2020 ,

Please update the codes for the last step as below and check whether it works or not:

#"Added Custom11" = Table.AddColumn(#"Renamed Columns19", "10 Day Notification Issued", each if [#"Customer Notification (days)"] = null then null else if [#"Customer Notification (days)"] < 10 then 1 else 0)

yingyinr_1-1622541034208.png

Best Regards

View solution in original post

3 REPLIES 3
Dunner2020
Post Prodigy
Post Prodigy

@selimovd , thanks for your reply. If I understood you correctly, you are asking to share the M script of the table where I am creating columns. If that's right, then here is the script

Anonymous
Not applicable

Hi @Dunner2020 ,

Please update the codes for the last step as below and check whether it works or not:

#"Added Custom11" = Table.AddColumn(#"Renamed Columns19", "10 Day Notification Issued", each if [#"Customer Notification (days)"] = null then null else if [#"Customer Notification (days)"] < 10 then 1 else 0)

yingyinr_1-1622541034208.png

Best Regards

selimovd
Super User
Super User

Hey @Dunner2020 ,

 

can you share the M Script as a sample or at least the full table.

I think there is a datatype mismatch. For example [InterruptionType]  is not a string or something similar.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors