Forum Discussion

NanduKris's avatar
NanduKris
New Member
10 months ago
Solved

Fuzzy matching

Hello guys, Is there an option to prevent self matching while performing fuzzy matching in Power Query.  If we only need similarity check for values against other values, but not against same value ...
  • ajaybabuinturi's avatar
    10 months ago

    HI NanduKris,

    Yes, you can prevent self-matching while performing fuzzy matching in Power Query Editor by default, Power Query allows fuzzy matching, and it might compare the values against themselves but you can modify the process to avoid this.

    Here is a simple approach to prevent self-matching:

    1. Add an Index Column:
      Before performing the fuzzy match, add an index column to your table. This will serve as a unique identifier for each row.
    2. Perform the Fuzzy Match:
      When you apply the fuzzy match, make sure you do it between two different queries/tables. In one of the queries, add the index column as a reference to ensure that you're not comparing values from the same row.
    3. Filter Out Self-Matches:
      After performing the fuzzy match, you can filter out any rows where the index of the matched value is the same as the index of the original row. This way, you will only keep the matches that are against different values.

    Example Steps:

    1. Create Two Queries:
      Have your primary table and a duplicate table (or reference) for the matching process.
    2. Add an Index to Both Queries:
      Add an index column to both tables (or the same table, if you’re referencing it).
    3. Apply Fuzzy Matching:
      Perform the fuzzy match between the two tables/queries using the index column to ensure you’re comparing rows correctly.
    4. Remove Self-Matches:
      Filter out the rows where the index from the match table is the same as the index from the original table.

    By doing this, you can ensure that Power Query Editor will not match a value to itself during fuzzy matching.

    Thanks,
    If you found this solution helpful, please consider giving it a Like👍 and marking it as Accepted Solution✔. This helps improve visibility for others who may be encountering/facing same questions/issues.