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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Doing a search against multiple strings

Hi,

 

The below should be relatively easy to fix in DAX but somehow I do not succeed.

 

For simplicity sake here is a dummy fact table:

 

ID

Content

Required Column

1

Text1,text2text3,text4,text5

2plus4

2

Text1

other

3

Text2,Text4

2plus4

4

Text1,text5

1pus5

5

Text1,Text4,Text5

1plus5

6

Text0Text2text99

Text2

7

Text 18

Other

 

I try to get a new (calculated) column that checks in the following order:

  1. Is “text2” and “text4” part of the content column? If so the new column should show “2plus4”
  2. Is “text1” and “text5” part of the content column? If so the new column should show “1plus5”
  3. Is there another column that contains “text2? If so the new column should “Text2”
  4. In all other cases the new column should show “Other”

 

Your help is appreciated,

(Worst)Kees

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , A new column like

 

Switch( True() ,
containsstring([Content],"text2") && containsstring([Content],"text2") , "2plus4",
containsstring([Content],"text1") && containsstring([Content],"text5") , "1plus5",
containsstring([Content],"text2"), "text2",
"Other")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@amitchandak thanks, this is brilliant.

Do you have any idea why "?" or "/?" is not working for my "text2" while if I use any other combination of characters, it works? No big deal (I created a workaround) but just curious.

Kind regatds & thanks again,
(Worst)Kees

 

amitchandak
Super User
Super User

@Anonymous , A new column like

 

Switch( True() ,
containsstring([Content],"text2") && containsstring([Content],"text2") , "2plus4",
containsstring([Content],"text1") && containsstring([Content],"text5") , "1plus5",
containsstring([Content],"text2"), "text2",
"Other")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.