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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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