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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
gerard-kouadio
Frequent Visitor

combine text.contains and or in M

Hello, I want to do something like this:

#"Colonne conditionnelle ajoutée" = Table.AddColumn(#"Type modifié", "New colonn", each if Text.Contains([colonne1], "xxx") then "x" else if Text.Contains([colonne1], "xxxy") then "x" else if Text.Contains([colonne1], "xxxd") then "x" else if Text.Contains([colonne1], "xxxg") then "x" else null). This code work well. But I have a lot of modalities and I want to use other code like this

 

#"Colonne conditionnelle ajoutée" = Table.AddColumn(#"Type modifié", "New colonn", each if Text.Contains([colonne1], "xxxx" or "xxxd" or "xxxg" or "xxxy") then "x" else null). It not working well and I need help to find the right code. Thanks a lot for your help

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

#"Colonne conditionnelle ajoutée" = Table.AddColumn(#"Type modifié", "New colonn", each if List.Contains({"xxx","xxxy","xxxd","xxxg"},[colonne1],(x,y)=> Text.Contains(y,x)) then "x" else null)

View solution in original post

3 REPLIES 3
wdx223_Daniel
Super User
Super User

#"Colonne conditionnelle ajoutée" = Table.AddColumn(#"Type modifié", "New colonn", each if List.Contains({"xxx","xxxy","xxxd","xxxg"},[colonne1],(x,y)=> Text.Contains(y,x)) then "x" else null)

Your code contains all the right elements, but this is exactly the one that works.

#"Colonne conditionnelle ajoutée" = Table.AddColumn(#"Type modifié", "New colonn", each if List.Contains({"xxx","xxxy","xxxd","xxxg"},[colonne1]) then "x" else null)

 

 

I know you used ,(x,y)=> Text.Contains(y,x)) for the explanations. Thank you so much

my code will give a "x" when [colonne1]="2123xxx212" or "zzzxxxydd", as long as it contains any string in the list.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors