The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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?
Solved! Go to Solution.
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
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
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.
User | Count |
---|---|
82 | |
82 | |
35 | |
32 | |
32 |
User | Count |
---|---|
93 | |
79 | |
62 | |
54 | |
51 |