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
electrobrit
Post Patron
Post Patron

in Power Query: If 2 columns contain specific text then this, else, this

Power Query: what is formula?
If Column A contains "arlene" and column B contains "arlene", then YES, otherwise, NO.

Column AColumn BCondition
John PetersArlene.Winters@e.comNO
Sherry De LeonKathy.Martin@E.comNO
jessica whithersKathy.Martin@E.comNO
Sandy Alan DomSandy.Dom@E.comNO
arlene w.Arlene.Winters@e.comYES
arlene w.Arlene.Winters@e.comYES
arlene w.Kathy.Martin@E.comNO
2 ACCEPTED SOLUTIONS
Zubair_Muhammad
Community Champion
Community Champion

Hi @electrobrit 

 

As a custom column

 

=Text.Contains([Column A],"arlene",Comparer.OrdinalIgnoreCase) 
and 
Text.Contains([Column B],"arlene",Comparer.OrdinalIgnoreCase)

Regards
Zubair

Please try my custom visuals

View solution in original post


@electrobrit wrote:

The column results are "error"


What was the error?

 


@electrobrit wrote:

1. how do I add the Yes if true, no if not? I tried to add at end and it didn't work.

= if Text.Contains([Column A],"arlene",Comparer.OrdinalIgnoreCase) 
and
Text.Contains([Column B],"arlene",Comparer.OrdinalIgnoreCase) = true then "YES" else "NO"

@electrobrit wrote:

2. it would not take the "and" so I used "&" and it seemed to work when doing custom column (it said not syntax error have been detected) but is that correct for what I'm trying to do?


'and' worked for me, unsure why it did not work for you

 






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



View solution in original post

4 REPLIES 4
Zubair_Muhammad
Community Champion
Community Champion

Hi @electrobrit 

 

As a custom column

 

=Text.Contains([Column A],"arlene",Comparer.OrdinalIgnoreCase) 
and 
Text.Contains([Column B],"arlene",Comparer.OrdinalIgnoreCase)

Regards
Zubair

Please try my custom visuals

@Zubair_Muhammad thank you for your response! 
The column results are "error"
1. how do I add the Yes if true, no if not? I tried to add at end and it didn't work.

2. it would not take the "and" so I used "&" and it seemed to work when doing custom column (it said not syntax error have been detected) but is that correct for what I'm trying to do?


@electrobrit wrote:

The column results are "error"


What was the error?

 


@electrobrit wrote:

1. how do I add the Yes if true, no if not? I tried to add at end and it didn't work.

= if Text.Contains([Column A],"arlene",Comparer.OrdinalIgnoreCase) 
and
Text.Contains([Column B],"arlene",Comparer.OrdinalIgnoreCase) = true then "YES" else "NO"

@electrobrit wrote:

2. it would not take the "and" so I used "&" and it seemed to work when doing custom column (it said not syntax error have been detected) but is that correct for what I'm trying to do?


'and' worked for me, unsure why it did not work for you

 






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



@Chris Thanks, I didn't have the "if" in front.That worked perfectly.

Thank you for both @Zubair_Muhammad  and @ChrisMendoza   for the great help 

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.