Forum Discussion
in Power Query: If 2 columns contain specific text then this, else, this
- 6 years ago
Hi electrobrit
As a custom column
=Text.Contains([Column A],"arlene",Comparer.OrdinalIgnoreCase) and Text.Contains([Column B],"arlene",Comparer.OrdinalIgnoreCase)
- 6 years ago
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
Hi electrobrit
As a custom column
=Text.Contains([Column A],"arlene",Comparer.OrdinalIgnoreCase) and Text.Contains([Column B],"arlene",Comparer.OrdinalIgnoreCase)
- electrobrit6 years ago
Post Patron
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?
- ChrisMendoza6 years ago
Resident Rockstar
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
- electrobrit6 years ago
Post Patron
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