+ Reply to Thread
Results 1 to 8 of 8

Power Query IndexMatch Lookup with multiple criteria

  1. #1
    Registered User
    Join Date
    10-09-2017
    Location
    Stavanger, Norway
    MS-Off Ver
    O365
    Posts
    78

    Power Query IndexMatch Lookup with multiple criteria

    Folks.
    I am building a Power Query model, and need help with coding a lookup with multiple criteria, similar to INDEX MATCH. The Index Mathc function is far too slow in Excel because I have large amounts of data. I suspect doing it in PowerQuery will be considerable faster.
    I have two tables called NPDFmTops and OHP_PLotData
    I want to return a value in the OHP_PlotData table, that comes from the NPDFmTops, based on 4 different criteria The INDEX/MATCH combo I wish to replicate in PowerQuery is

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    In otherwords
    return IsuName
    When Wellbore=wlbName AND
    IsuLevel = "FORMATION" AND
    MD RKB > IsuTopDepth AND
    MD RKB <= IsuBottomDepth

    I have added a small example file with 2 TABLES "OHP_PlotData" and "NPDLithostrat" both added to the Data Model as Links Only... I wish the above INDEX/MATCH combo to be built into PowerQuery adding data to the Column "FORMATION" in the "OHP_PLotData" Table

    Can anyone help in writing the correct PowerQuery Code to replicate this, I'm struggling considerably

    Thanks
    Attached Files Attached Files
    Last edited by SimonCampbell; 10-27-2021 at 03:20 AM. Reason: Add Attachment

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,759

    Re: Power Query IndexMatch Lookup with multiple criteria

    There are instructions at the top of the page explaining how to attach your sample workbook.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    10-09-2017
    Location
    Stavanger, Norway
    MS-Off Ver
    O365
    Posts
    78

    Re: Power Query IndexMatch Lookup with multiple criteria

    I would gladly upload a sample Workbook.. BUT I can't make it small enough, cutting out large amounts of data still only gets to 3000 KB

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,759

    Re: Power Query IndexMatch Lookup with multiple criteria

    Then you need to cut it some more. What's causing the bloat? Do you have full column references in your formulae (e.g. A:A)? Do you have a lot of conditional formatting?

    We need only 10-20 rows of sample data in order to be able to offer a solution.

  5. #5
    Registered User
    Join Date
    10-09-2017
    Location
    Stavanger, Norway
    MS-Off Ver
    O365
    Posts
    78

    Re: Power Query IndexMatch Lookup with multiple criteria

    I have added a Small test version of what I'm trying to do.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,990

    Re: Power Query IndexMatch Lookup with multiple criteria

    You could load your main lookup table as a query called Formation_NPDLIthostrat, filtering it for only records of FORMATION level. Then amend your OHP_PlotData query to something like:

    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

  7. #7
    Registered User
    Join Date
    10-09-2017
    Location
    Stavanger, Norway
    MS-Off Ver
    O365
    Posts
    78

    Re: Power Query IndexMatch Lookup with multiple criteria

    Rory.. if I actually include all the pertinent data in a "new" query that looks at the tables(queries) will I then only need the "add custom column" script ? I am VERY new to PowerQuery but can see the big benefits. My original problem was caused by very slow performance when I used a FILTER or INDEX/MATCH combo in excel, do you think doing it in PowerQuery will help (or for that matter PowerPivot). In my data set the TABLE NPDLithostrat I have 37000 rows. There's o point in doing this if performance doesn't improve. But I can use the Worrkbook without continually refreshing the connections, only refreshing on OPEN... what do you think?

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,990

    Re: Power Query IndexMatch Lookup with multiple criteria

    Quote Originally Posted by SimonCampbell View Post
    if I actually include all the pertinent data in a "new" query that looks at the tables(queries) will I then only need the "add custom column" script ?
    It depends what you mean by that - it's not clear to me at all. You need the lookup table as a query somewhere.

    My original problem was caused by very slow performance when I used a FILTER or INDEX/MATCH combo in excel, do you think doing it in PowerQuery will help (or for that matter PowerPivot). In my data set the TABLE NPDLithostrat I have 37000 rows. There's o point in doing this if performance doesn't improve. But I can use the Worrkbook without continually refreshing the connections, only refreshing on OPEN... what do you think?
    It won't take long to try it and see, so...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] IndexMatch with Multiple Criteria and columns
    By Perk1961 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-24-2021, 10:08 PM
  2. IndexMatch a merged Power Query excel 2013
    By BrianThompson in forum Excel General
    Replies: 3
    Last Post: 07-13-2021, 11:07 AM
  3. lookup in Power Query
    By hudson andrew in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-26-2021, 08:22 AM
  4. Replies: 8
    Last Post: 04-28-2020, 01:34 PM
  5. Sub-Forum for Excel Power Tools (Power Query, Power Pivot & Power BI)
    By chullan88 in forum Suggestions for Improvement
    Replies: 10
    Last Post: 06-28-2018, 02:25 PM
  6. [SOLVED] Power Query to Extract Data based on multiple criteria
    By Philipsfn in forum Excel Formulas & Functions
    Replies: 27
    Last Post: 01-16-2018, 01:45 PM
  7. Lookup type query with multiple criteria
    By The_Snook in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-10-2014, 09:08 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1