Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Fuzzy matching logic

I have already removed the extensions using this M code in Power Query.   let // Load your Excel file/table Source = Excel.Workbook(File.Contents("C:\Users\mark.jz.yeap\Documents\ATCi - Mark\Matc...
  • v-pnaroju-msft's avatar
    1 year ago

    Thankyou, lbendlin, for your response.

    Hi Mark-JZ-Yeap,

    We appreciate your inquiry through the Microsoft Fabric Community Forum.

    Based on my understanding, you are seeking to match the RawAccount column against a reference company list using fuzzy logic, with varying similarity thresholds depending on the length of each cleaned name. As Power BI’s fuzzy matching in Power Query does not directly support dynamic thresholds for each row, please follow the steps outlined below, which may assist in resolving the issue:

    1. Continue using your suffix-removal M script to cleanse both the RawAccount and reference list.
    2. Add two columns: one for the string length and another to assign a similarity threshold based on that length.
    3. Split your dataset into three categories: Length ≤ 4 → exact match (threshold = 1.0); Length = 5 → fuzzy match (threshold = 0.9); and Length > 5 → fuzzy match (threshold = 0.8).
    4. Perform merges accordingly using Power Query’s fuzzy matching feature.
    5. Recombine the results using Append Queries.

    This method effectively replicates your logic without any manual matching requirements and will scale well.

    Additionally, please refer to the following links for more information:
    How fuzzy matching works in Power Query - Power Query | Microsoft Learn
    Merge queries overview - Power Query | Microsoft Learn

    If you find our response helpful, kindly mark it as the accepted solution and provide kudos. This will assist other community members facing similar queries.

    Thank you.