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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
andris_
Resolver I
Resolver I

AND() function

Hi everyone,

 

I'm trying to create a column which checks if two other columns contains some expressions. So I tried to create that column, this is how it looks like:

Column = if(AND(Text.Contains([Column1], "something"), Text.Contains([Column2], "anything"))) then "result" else "other"

 

But it is not working for me, and I have no idea why, and I couldn't find any solution for it.

 

This is the error message I got:

Expression.Error: The name 'AND' wasn't recognized.  Make sure it's spelled correctly.

 

Anybody has any idea how to solve it/make it right?

 

Thanks in advance.

1 ACCEPTED SOLUTION
LaurentCouartou
Solution Supplier
Solution Supplier

AND() is an Excel function. What you are looking for is just to use "and" as an operator.

 

Column = if Text.Contains([Column1], "something") and Text.Contains([Column2], "anything") then "result" 
else "other"

View solution in original post

6 REPLIES 6
Justas4478
Post Prodigy
Post Prodigy

I am trying to write something similar but for DAX filter.

This is what I have so far but 'and' does not seem to work.

Justas4478_0-1699347618133.png

I cant seem to find what is correct operator for 'and'.

Thanks

Maysantos
New Member

Can someone help me please with the syntax error:


Album "C" =

    var v_A = if("for Sampling"[A] = "N",1,0)

the error says: The syntax for '[A]' is incorrect. (DAX( var v_A = if("for Sampling"[A] = "N",1,0))
LaurentCouartou
Solution Supplier
Solution Supplier

AND() is an Excel function. What you are looking for is just to use "and" as an operator.

 

Column = if Text.Contains([Column1], "something") and Text.Contains([Column2], "anything") then "result" 
else "other"

Oh, I see. Thank you very much!

andris_
Resolver I
Resolver I

Hi everyone,

 

I'm trying to create a column which checks the content of 2 existing columns and if column1 contains "something" and column2 contains "anything" then "result1" else "result2".

 

This is how it looks like: Column = if(AND(Text.Contains([Column1], "something"), Text.Contains([Column2], "anything"))) then "result" else "other"

 

There is no syntax error in it, but if I try to create it, it gives me this error message: "Expression.Error: The name 'AND' wasn't recognized.  Make sure it's spelled correctly."

 

Anyone has any idea what is the problem with it?

 

Thanks in advance.

Where are you writing this?  As dax or PQL?  

 

Read "2 ways to add a column" in this post http://exceleratorbi.com.au/shaping-modelling-power-bi/

 

this task is best done in Power Query (get data). There is no and function in power query. The syntax is

 

= if [column1] = "something" and [column2] = "whatever" then "x" else "y"



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

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 MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.