• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Filtering a table based on a list with contains or wild characters|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Filtering a table based on a list with contains or wild characters|Power Query|Excel Forum|My Online Training Hub

vba course banner

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower QueryFiltering a table based on a list w…
sp_PrintTopic sp_TopicIcon
Filtering a table based on a list with contains or wild characters
Avatar
JEAN-CLAUDE BRUNET

New Member
Members
Level 0
Forum Posts: 2
Member Since:
July 23, 2021
sp_UserOfflineSmall Offline
1
July 23, 2021 - 8:56 pm
sp_Permalink sp_Print

Hello,

I am not an expert with PQ and struggle to filter a table based on a list already created. 

I have a table containing contacts and a list of specific contacts. I want to filter my table Contact with this list BUT with an equivalent of contains or wild characters as it might not be a 100% match.

As an exemple if my list has "Air France" i want to find any expression in the Contact table containing "Air France" which could then be:

Air France

Air France Industries -KLM Engineering

Air France - KLM

Not sure i was very clear.

Any clue to solve this as I am stuck

Thznks for your help

JC

Avatar
Chris Yap
Member
Members
Level 0
Forum Posts: 162
Member Since:
August 21, 2019
sp_UserOfflineSmall Offline
2
July 24, 2021 - 1:04 am
sp_Permalink sp_Print

Hi JC,

not sure this is what you want

create a lookup and input all the keywords of your contact description (Air France, Air UK etc),   bring this table to Power Query and name the table as Lookup (or whatever name you want),   bring in the contact table to Power query too,  create a custom column and merge the Lookup table,  then create another custom table to match with each keywords,  then filter off null and all your contact description is now tag with a category

 

Complete code as below

let
Source = Excel.CurrentWorkbook(){[Name="Contacts"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Contact Description", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Lookup),
#"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Lookup"}, {"Lookup"}),
#"Added Custom1" = Table.AddColumn(#"Expanded Custom", "Custom", each if Text.Contains([Contact Description],[Lookup]) then [Lookup] else null),
#"Filtered Rows" = Table.SelectRows(#"Added Custom1", each ([Custom] <> null)),
#"Renamed Columns" = Table.RenameColumns(#"Filtered Rows",{{"Custom", "Category"}}),
#"Removed Columns" = Table.RemoveColumns(#"Renamed Columns",{"Lookup"})
in
#"Removed Columns"

Avatar
JEAN-CLAUDE BRUNET

New Member
Members
Level 0
Forum Posts: 2
Member Since:
July 23, 2021
sp_UserOfflineSmall Offline
3
July 26, 2021 - 6:17 pm
sp_Permalink sp_Print

Hi Chris,

First of all thanks a lot for your help.

Unfortunately it doesn't work as expected. My contact Table has  2682 rows and my Lookup Table 119 rows and i only get 23 rows matching which isn't correct.

My Lookup items are in uppercase while my Contacts have only an uppercase at the beginning of each words. Not sure this is making the difference

Any idea? I attached my file. 

Thanks

Avatar
Chris Yap
Member
Members
Level 0
Forum Posts: 162
Member Since:
August 21, 2019
sp_UserOfflineSmall Offline
4
July 27, 2021 - 12:04 am
sp_Permalink sp_Print

Hi JC,

Added Text.Upper() inside the M Code,   in the query will convert both contacts and match lookup all in Upper Case,  as for output I am not sure whether you want to be upper case or only first character upper only,  if it is the latter then apply Text. Proper( )

by the way,  you didn't attach your file.

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Louis Muti, Misael Gutierrez Sr.
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 218
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Cathi Giard
Sarah Young
Henry Delgado
Alita Nieuwoudt
KL KOH
Joao Marques
Regi Hampton
Taffie Elliott
Paramita Chakraborty
David du Toit
Forum Stats:
Groups: 3
Forums: 24
Topics: 6358
Posts: 27805

 

Member Stats:
Guest Posters: 49
Members: 32335
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.