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
Anonymous
Not applicable

Finding Values that Contains text no matter which order it is in

Hi, 

 

I hope all is well. I am working on a project for my team. I have a column in my table that contains a certain amount of codes in one string. What I want to do is create a column where if I type in ANY code I will get a list of people who have that code in their column. It seems as if the code I am using is only bringing the first value/code that exists for that person. 

 

Here's my code......custom column....

= if Text.Contains ([descriptor] , "ALUM") then "ALUMS"

else if Text.Contains ([descriptor] , "ALND") then "non"

else if Text.Contains ([descriptor] , "FRND") then "Friend"

else " "

 

This code only brings back those people where the code is the first value in that string. Someone might have codes FRND ALUM, but if I chose ALUMS from the filter this person won't show because ALUM is not the first code. How can i make this work where if I type in a code I want everyone to show who has that code no matter which order it is in?

 

Please help!!!

2 REPLIES 2
Greg_Deckler
Super User
Super User

I don't see how you could do this in Power Query if you desire user interaction. I would do this in DAX using CONTAINSSTRING and I wouldn't use a calculated column, I would use a measure.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Can you please show me an example where I can use it using CONTAINSSTRING for a measure?


@Greg_Deckler wrote:

I don't see how you could do this in Power Query if you desire user interaction. I would do this in DAX using CONTAINSSTRING and I wouldn't use a calculated column, I would use a measure.


 

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.