Forum Discussion
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:
Then I created a conditional column using the following logic:
However, it throws error of "Expression. Error: We cannot convert the value null to type Logical.
Could anyone help me where I made the mistake?
- Anonymous5 years ago
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) Best Regards
3 Replies
- selimovdMost Valuable Professional
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 regardsDenisBlog: WhatTheFact.biFollow me: twitter.com/DenSelimovic - Dunner2020Post Prodigy
- AnonymousNot 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) Best Regards