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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
sureshrawat048
Regular Visitor

Error while adding Custom Column in Power Query

Hi Team, getting errow on applying if condition in powerquery custom column.

Wanted to achieve : if condition 1 if column contain date after 1st Jan 2023 or column 2 contain value length > 9 then "Yes" Else "No" and in case of no criteria matches then it should not through error it shouldshow null value.Error_PowerQuery.jpg 

1 ACCEPTED SOLUTION
v-hashadapu
Community Support
Community Support

Hi @sureshrawat048Hope your issue is solved. If it is, please consider marking the answer 'Accept as solution', so others with similar issues may find it easily. If it isn't, please share the details.
Thank you.

View solution in original post

9 REPLIES 9
v-hashadapu
Community Support
Community Support

Hi @sureshrawat048Hope your issue is solved. If it is, please consider marking the answer 'Accept as solution', so others with similar issues may find it easily. If it isn't, please share the details.
Thank you.

v-hashadapu
Community Support
Community Support

Hi @sureshrawat048 , Hope your issue is solved. If it is, please consider marking the answer 'Accept as solution', so others with similar issues may find it easily. If it isn't, please share the details.
Thank you.

v-hashadapu
Community Support
Community Support

Hi @sureshrawat048 , Hope your issue is solved. If it is, Please consider marking the answer 'Accept as Solution', if it isn't, please share the details along with sample data for us to work to solve it. Thank you.

ZhangKun
Super User
Super User

Because the condition of the if keyword cannot be null. The meaning of null is missing and unknown, and null obviously cannot be used for "judgment".You need to make additional judgments when the value of the "conditon1" column or the "numeric cell" column is null.

 

In addition, although the expression "if[Condition 1]" can be recognized by the program, it is better to write it as "if [Condition 1]" (add a space character).

sureshrawat048
Regular Visitor

Error_PowerQuery.jpg

@sureshrawat048 

I believe you are using Power Query in Excel. What is the result of this custom column in Power Query data preview? is there any error? if yes then please share the error message. If you are not able to see the error in the preview that does not mean there are no errors, by default power query profiles only 1000 rows, So I would suggest you to click on "Keep Errors" transformation and find the error message. 

 

I am guessing Date.FromText could be a possible reason for the errors. If Power Query cannot parse it as a proper date then it can through an error. You need explictly mention the format. For example 


Date.FromText( "2023-31-12", [Format="yyyy-dd-M" ] )

 

https://powerquery.how/date-fromtext/

 

Please share the error message for further assistance 

 

Need a Power BI Consultation? Hire me on Upwork

 

 

 

Connect on LinkedIn

 

 

 








Did I answer your question? Mark my post as a solution!
If I helped you, click on the Thumbs Up to give Kudos.

Proud to be a Super User!


PBI_SuperUser_Rank@2x.png

Hi, Error : 

Expression.Error: We cannot convert the value null to type Logical.
Details:
Value=
Type=[Type]

@sureshrawat048 

This error message suggests that you have a column with null values and you are using it as logical value (TRUE/FALSE) in an expression.

Handle this exception and see it that helps

 

Need a Power BI Consultation? Hire me on Upwork

 

 

 

Connect on LinkedIn

 

 

 








Did I answer your question? Mark my post as a solution!
If I helped you, click on the Thumbs Up to give Kudos.

Proud to be a Super User!


PBI_SuperUser_Rank@2x.png
Omid_Motamedise
Super User
Super User

click on one error and share the text related to the error.

I think it con be solve by replacing if[Condition1] with if Date.From([Condition 1]) and also replacing [#"numerical cell"] with [Numerical Cell]

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors