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
icturion
Resolver II
Resolver II

See if column string contains multiple text values

Hi,

 

Is there a way to search for two or more words within the same string of text?

 

I already tried with containsstring but then I can only give one word.

 

Example data:

Column
this text contains two words I want to search for to determine which group the content belongs to
this is another sentence where the content belongs to a different group

 

if the text contains the following words "text" and "search" then group 1,

if the text contains the following words "sentence" and "different" then group 2,

otherwise group 3

 

Searching for one word in the text is no problem, I have that working, I just can't figure it out if several words have to be looked at. hopefully someone knows a solution. thanks in advance

1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

Hi @icturion ,

 

Create a column with below code:-

Column 2 =
SWITCH (
    TRUE (),
    CONTAINSSTRING ( 'Table (4)'[Column], "text" )
        && CONTAINSSTRING ( 'Table (4)'[Column], "search" ), "Group 1",
    CONTAINSSTRING ( 'Table (4)'[Column], "sentence" )
        && CONTAINSSTRING ( 'Table (4)'[Column], "different" ), "Group 2",
    "Group 3"
)

Output:-

Samarth_18_0-1644224471624.png

 

Thanks,

Samarth

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

3 REPLIES 3
Samarth_18
Community Champion
Community Champion

Hi @icturion ,

 

Create a column with below code:-

Column 2 =
SWITCH (
    TRUE (),
    CONTAINSSTRING ( 'Table (4)'[Column], "text" )
        && CONTAINSSTRING ( 'Table (4)'[Column], "search" ), "Group 1",
    CONTAINSSTRING ( 'Table (4)'[Column], "sentence" )
        && CONTAINSSTRING ( 'Table (4)'[Column], "different" ), "Group 2",
    "Group 3"
)

Output:-

Samarth_18_0-1644224471624.png

 

Thanks,

Samarth

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

Is there a way I could work this function to support a sequence of words? 

 

For example, 

 

I want two groups one if the text contains "collab" and "workstations" = group 1 and another if the text contains "collab" and "no workstations" = group 2

Thank you, I hadn't thought of the switch function. thanks for thinking along

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.