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
natabird3
Continued Contributor
Continued Contributor

Create a custom column that filters only specific text values M Query

Dear all,

 

I am trying to create a custom column that will be filtered based on a list of specific text values (200+ text values for example). So for example i have the following sample data and expected result needed:

NameValueCustom Column needed (filter applied contains J)
Jake121
Betty150
Jordan251
Nate1250

 

Can someone help me out with the query as i have tried with a list.contains and text.contains but for some reason cannot make it filter anything and get a full error for all rows? Thanks in advance for the help.

1 ACCEPTED SOLUTION
natabird3
Continued Contributor
Continued Contributor

Ok, I found the following solution to work for my case:
= Table.AddColumn(#"Added Conditional Column", "Name", each if Text.Contains([Contacts],"Jake") then 1
else if Text.Contains([Contacts],"Jane") then 1
else if Text.Contains([Contacts],"Betty") then 1
...
else 0)
The only note! is that if a value is written jake instead of Jake it will not get it, so its case sensitive. Hope this helps to others having my problem 🙂

View solution in original post

1 REPLY 1
natabird3
Continued Contributor
Continued Contributor

Ok, I found the following solution to work for my case:
= Table.AddColumn(#"Added Conditional Column", "Name", each if Text.Contains([Contacts],"Jake") then 1
else if Text.Contains([Contacts],"Jane") then 1
else if Text.Contains([Contacts],"Betty") then 1
...
else 0)
The only note! is that if a value is written jake instead of Jake it will not get it, so its case sensitive. Hope this helps to others having my problem 🙂

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.