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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

"Expression Error: The name"AND" wasn't recognized..." issue

I was trying to add a custom column by typing: =if (AND([Column_1]="AAA",[Column_2]="BBB"))then "XXX"else if (AND([Column_1] = "AAA", [Column_2]=OR ("CCC","DDD","EEE")))then "XXX" else if (AND([Column_1]= null, [Column_2]=OR("CCC","DDD", "EEE")))then [Column_2] else"" However, the below message popped out: "Expression Error: The name"AND" wasn't recognized..." Does anyone know how to fix it? Thank you so much!
1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

@Anonymous,

 

In M Code, the formula should be:

= if [Column_1] = "AAA" and [Column_2] = "BBB" then "XXX" else if [Column_1] = "AAA" and List.Contains({"CCC","DDD","EEE"}, [Column_2]) then "XXX" else if [Column_1] = null and List.Contains({"CCC","DDD", "EEE"}, [Column_2]) then [Column_2] else "" 

Regards,

Jimmy Tao

View solution in original post

2 REPLIES 2
v-yuta-msft
Community Support
Community Support

@Anonymous,

 

In M Code, the formula should be:

= if [Column_1] = "AAA" and [Column_2] = "BBB" then "XXX" else if [Column_1] = "AAA" and List.Contains({"CCC","DDD","EEE"}, [Column_2]) then "XXX" else if [Column_1] = null and List.Contains({"CCC","DDD", "EEE"}, [Column_2]) then [Column_2] else "" 

Regards,

Jimmy Tao

ryan_mayu
Super User
Super User

@Anonymous

 

The custome column has to write in M language. You need to put AND between conditions.

e.g  if column1=xxx and column2= xxx then xxx else xxx

If you want to use DAX to create a column you should write like AND (xxx,xxx)

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors