Forum Discussion
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 itself.
Thanks
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:
- 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. - 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. - 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:
- Create Two Queries:
Have your primary table and a duplicate table (or reference) for the matching process. - Add an Index to Both Queries:
Add an index column to both tables (or the same table, if you’re referencing it). - Apply Fuzzy Matching:
Perform the fuzzy match between the two tables/queries using the index column to ensure you’re comparing rows correctly. - 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.- Add an Index Column:
3 Replies
- ajaybabuinturiSuper User
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:
- 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. - 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. - 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:
- Create Two Queries:
Have your primary table and a duplicate table (or reference) for the matching process. - Add an Index to Both Queries:
Add an index column to both tables (or the same table, if you’re referencing it). - Apply Fuzzy Matching:
Perform the fuzzy match between the two tables/queries using the index column to ensure you’re comparing rows correctly. - 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. - Add an Index Column:
- ThomasWepplerImpactful Individual
Hey try this.
If it helps than please accept the solution and give a kudos. 🙂
- v-hjannapuCommunity Support
Hi NanduKris,
I would also take a moment to thank ajaybabuinturi , ThomasWeppler for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.
Regards,
Community Support team.