• 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
  • Login

Merge Two tables - match Table_1 with either col_1, or col_2, or col_3, or col_4 from Table_2|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Merge Two tables - match Table_1 with either col_1, or col_2, or col_3, or col_4 from Table_2|Power Query|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
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 QueryMerge Two tables - match Table_1 wi…
sp_PrintTopic sp_TopicIcon
Merge Two tables - match Table_1 with either col_1, or col_2, or col_3, or col_4 from Table_2
Avatar
Robert Green
Member
Members
Level 0
Forum Posts: 25
Member Since:
November 9, 2020
sp_UserOfflineSmall Offline
1
May 19, 2022 - 5:59 pm
sp_Permalink sp_Print

Hello again,

I have a connection to a sheet with 5 million rows in the table and want to filter the rows with a value that is in column_1 or in column_2 or in column_3 or in column_4.

So I'm using PQ with a second table containing the search terms and trying to merge the tables.

There might be 100k results from column_1, 50k from column_2, 25k from column_3 and 10k from column_4. I would like a single result with all 185k rows.

I can do this for one column, but struggling to do it on multiple columns. Can you advise please?

Thanks 

Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators
Level 1
Forum Posts: 614
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
2
May 19, 2022 - 6:53 pm
sp_Permalink sp_Print

Perhaps you can upload a small data set demonstrating what you have in mind. Raw data as you would find it in the 5 million row table, the table with the search terms and the desired end result.

Avatar
Robert Green
Member
Members
Level 0
Forum Posts: 25
Member Since:
November 9, 2020
sp_UserOfflineSmall Offline
3
May 20, 2022 - 2:55 am
sp_Permalink sp_Print

I've attached a file with an example source table (the original has 5m rows), a table with >1 search terms, and a table what the results would look like.

I can perform 4 merges in PQ to get a results for each column merge and then append the results, but I am wondering if it is possible to perform the search in one merge or similar?

Note that Ethan and Oliver appear in both searches but result in only one 'find'

Thanks

Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators
Level 1
Forum Posts: 614
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
4
May 20, 2022 - 4:18 am
sp_Permalink sp_Print

Thanks, but I don't see a file. Did you press the "Upload" button?

Avatar
Robert Green
Member
Members
Level 0
Forum Posts: 25
Member Since:
November 9, 2020
sp_UserOfflineSmall Offline
5
May 20, 2022 - 6:51 pm
sp_Permalink sp_Print

Hmm. Obviously not 🙂

Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators
Level 1
Forum Posts: 614
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
6
May 20, 2022 - 8:20 pm
sp_Permalink sp_Print sp_EditHistory

The attached file contains two possible solutions. One that begins with a traditional UNPIVOT step, then one merge with the Search table. Filter out the nulls, remove duplicates and merge again with the original source.

An alternative solution seem much neater. It converts the source to one column with lists that are then checked against the items in the Search table. Filter and convert a single column of lists back to a regular table.

Both work, but I can't really oversee which how either of them will perform in i.r.l. on a table with 5 million rows.

Avatar
Robert Green
Member
Members
Level 0
Forum Posts: 25
Member Since:
November 9, 2020
sp_UserOfflineSmall Offline
7
May 21, 2022 - 8:01 pm
sp_Permalink sp_Print

Thank you Riny. Very interesting results. I need to get a DAX course!!

I wil have a go with the large file and see how they respond.

Warm regards

Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators
Level 1
Forum Posts: 614
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
8
May 21, 2022 - 9:02 pm
sp_Permalink sp_Print

Hi Robert,

Glad I could help! And, by the way, DAX relates to Power Pivot / Data Model. You'll need to dive into M, the code language that drives Power Query, in order to follow some of the techniques used here.

Power Query M formula language reference - PowerQuery M | Microsoft Docs

Curious to hear how it goes with real data on a much larger scale.

Avatar
Robert Green
Member
Members
Level 0
Forum Posts: 25
Member Since:
November 9, 2020
sp_UserOfflineSmall Offline
9
May 25, 2022 - 12:50 am
sp_Permalink sp_Print

Of course! 

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Alan Sidman
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 880
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 237
Jessica Stewart: 219
A.Maurizio: 213
Aye Mu: 201
Hans Hallebeek: 185
Newest Members:
Appiagyei Kofi Frimpong
Hilary Burchfield
Richie Wright
Adel Kock
Barbara Murray
Doug Milne
Siobhan Stringer
Rob Rooth
Tom Lewis
Jennifer Rodriguez-Avila
Forum Stats:
Groups: 3
Forums: 24
Topics: 6542
Posts: 28641

 

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

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel Office Scripts
  • 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

Sign up to our newsletter and join over 400,000
others who learn Excel and Power BI with us.

 

Company

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

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.