+ Reply to Thread
Results 1 to 11 of 11

Power Query Merge - Closest Match

  1. #1
    Forum Contributor
    Join Date
    07-10-2020
    Location
    New Zealand
    MS-Off Ver
    365 personal
    Posts
    302

    Power Query Merge - Closest Match

    Hi

    I have a table where I need to replace values in a field based on the closest match of two other columns.

    The attached workbook sets out the solution I am seeking

    Allister
    Attached Files Attached Files
    Last edited by AllisterB; 07-27-2023 at 11:47 PM.

  2. #2
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,427

    Re: Power Query Merge - Closest Match

    Please check the value of E13 (confirm the expected results it should be C instead of B) and try
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    07-10-2020
    Location
    New Zealand
    MS-Off Ver
    365 personal
    Posts
    302

    Re: Power Query Merge - Closest Match

    I Have updated the workbook
    @HansDouwe
    Attached Files Attached Files
    Last edited by AllisterB; 07-28-2023 at 01:21 AM.

  4. #4
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,427

    Re: Power Query Merge - Closest Match

    Thanks,

    I corrected the workbook also in Post #2.
    There is also a solution.

  5. #5
    Forum Contributor
    Join Date
    07-10-2020
    Location
    New Zealand
    MS-Off Ver
    365 personal
    Posts
    302

    Re: Power Query Merge - Closest Match

    Hi

    Is There alos a Power Query Solution ?

    Thanks

  6. #6
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,427

    Re: Power Query Merge - Closest Match

    Sure, but I'll leave that to the Power Query experts.
    I have less experience with that.
    Last edited by HansDouwe; 07-28-2023 at 01:40 AM.

  7. #7
    Forum Contributor
    Join Date
    07-10-2020
    Location
    New Zealand
    MS-Off Ver
    365 personal
    Posts
    302

    Re: Power Query Merge - Closest Match

    I would welcome a Power Query solution

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,853

    Re: Power Query Merge - Closest Match

    So you have said and you will I am sure get one - but you will need to be patient. You should not be bumping a thread after only two hours - 24 hours is OK.
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  9. #9
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Power Query Merge - Closest Match

    Assuming there is always a prior value for any -1 Key value, you can sort on key then date, then replace the -1 with null, then fill down:

    Please Login or Register  to view this content.
    Rory

  10. #10
    Forum Contributor
    Join Date
    07-10-2020
    Location
    New Zealand
    MS-Off Ver
    365 personal
    Posts
    302

    Re: Power Query Merge - Closest Match

    Thank You - a nice - non-PQ Solution
    Last edited by AllisterB; 07-31-2023 at 12:04 AM.

  11. #11
    Forum Contributor
    Join Date
    07-10-2020
    Location
    New Zealand
    MS-Off Ver
    365 personal
    Posts
    302

    Re: Power Query Merge - Closest Match

    Thank You Rory.

    Your comment "Assuming there is always a prior value for any -1 Key value" got me thinking.

    I have attached my solution which Uses Group By and then Table.FillUp Table.FillDown.

    I first did this for the Key. Then I did the same thing for the Supervisor on the basis that a good predictor for where there is no prior key value is the Branch for the next instance of the same Supervisor Column.

    Allister
    Attached Files Attached Files

+ 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. Replies: 15
    Last Post: 10-29-2019, 06:46 AM
  2. [SOLVED] Find address of closest match/second closest match
    By L.LEE in forum Excel General
    Replies: 1
    Last Post: 11-13-2018, 11:56 PM
  3. Return closest value less than given number matching another column - Power Query ?
    By ChipsSlave in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-29-2017, 03:16 PM
  4. Power Pivot - Lookup based on Last Closest Date/Time
    By ELeGault in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 04-17-2015, 06:48 AM
  5. Replies: 2
    Last Post: 12-18-2014, 09:52 AM
  6. mail merge, option to not choose closest match from active directory?
    By kuraitori in forum Word Formatting & General
    Replies: 0
    Last Post: 11-25-2009, 08:38 PM
  7. Replies: 0
    Last Post: 08-25-2005, 02:37 AM

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