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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Error with code

Dear all,

 

I have writted below code to conditional custom column

 

if [Plnt]="776" and [DP]="0776" and [P] = "E" then "Manufactured"
else "other"

 

But column shows all values as "Other". But no syntax error found. 

@d_gosbell , Can you check this?Untitled.jpg

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Does this work?

=if [Plnt]=776 and [DP]="0776" and [P] = "E" then "Manufactured" else "other"

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
saraMissBI
Resolver I
Resolver I

Hi @Anonymous 

 

I think there must be something in the evaluation of the if statement. Try to check the data type of your columns Plnt, DP, and P and update the formula accordingly.

 

I hope that could help

Regards  

Ashish_Mathur
Super User
Super User

Hi,

Does this work?

=if [Plnt]=776 and [DP]="0776" and [P] = "E" then "Manufactured" else "other"

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Specifically note the difference between the code for [DP] that @Ashish_Mathur  posted compared to the code in your screenshot (not the code you pasted into this post which is different from the screen shot). [DP] is a text column so you need to compare it to "0776" if you type 0776 without the quotes this will get interpreted as the number 776 as the leading 0 is not significant in numeric values. You could test this yourself by temporarily creating 3 calc columns with each of the 3 conditions to see which one was not working as expected.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.