Excel Formulas for Aggregating Fuzzy Matching Names with Similarity Scores

📅 Apr 16, 2026 📝 Sarah Miller

Reconciling inconsistent client and entity names in Excel remains a tedious, error-prone obstacle for finance professionals. When auditing capital allocation, teams must routinely aggregate disparate data from standard funding sources like federal grants, venture portfolios, and private endowments. Deploying an advanced fuzzy matching formula grants organizations the power to automatically unify mismatched records while generating precise similarity scores. As a vital educational stipulation, however, users must calibrate strict threshold limits to avoid false positives. For example, distinguishing "Capital One" from "Capital 1" requires exact percentage-based tuning. Below, we detail the step-by-step methodology to build this robust aggregation formula.

Excel Formulas for Aggregating Fuzzy Matching Names with Similarity Scores

Data normalization is one of the most common yet frustrating challenges in data analysis. When merging databases, managing CRM contact lists, or consolidating sales figures, you are bound to encounter variations of the same name. "Microsoft Corp," "Microsoft Corporation," "Microsoft," and "Micro soft" all represent the same entity, but to traditional Excel formulas like VLOOKUP, XLOOKUP, or SUMIFS, they are completely different strings.

To consolidate these records, we must use fuzzy matching. This technique calculates a similarity score between two text strings and groups them if they meet a specific threshold. While legacy versions of Excel required complex VBA or external add-ins, modern Excel offers native solutions like Power Query, alongside custom formula-based architectures to aggregate and analyze fuzzy-matched names seamlessly.

In this guide, we will explore the best methods to aggregate values from fuzzy-matched names, complete with step-by-step instructions, formulas, and VBA workflows.

Method 1: The Modern Standard – Power Query Fuzzy Merge & Grouping

The most robust, scalable, and native way to handle fuzzy matching and aggregation in Excel is through Power Query (available in Excel 2016 and later). Power Query features a built-in fuzzy matching engine based on the Jaccard index similarity algorithm.

Scenario

Imagine you have a sales table containing names with typos and variations, and you want to aggregate the total sales for each unique client group.

Customer Name (Raw) Sales Amount
Acme Corp. $1,200
Acme Corporation $850
Akme Corp $450
Globex LLC $3,000
Globex Ltd. $1,500

Step-by-Step Power Query Implementation

  1. Load your data: Select your dataset, go to the Data tab, and click From Table/Range to open the Power Query Editor.
  2. Create a Master List: To group these names, you need a "Master" reference list of clean names. If you do not have one, you can duplicate your query, remove duplicates, and clean it up manually to serve as your mapping table.
  3. Perform a Fuzzy Merge:
    • In Power Query, go to the Home tab > Merge Queries as New.
    • Select your raw data table as the first table, and your clean Master List as the second table.
    • Select the Name columns in both previews.
    • Check the box for Use fuzzy matching to perform the merge.
  4. Configure Fuzzy Options: Click on Fuzzy matching options to fine-tune the match:
    • Similarity Threshold: Set a value between 0.00 and 1.00. A score of 0.80 is generally the optimal balance for catching typos while avoiding false positives.
    • Ignore Case / Match by combining parts: Keep these checked to ignore capitalization and handle words in different orders (e.g., "John Smith" vs. "Smith, John").
  5. Expand and Group:
    • Once merged, click the expand icon in the new column and select only the "Master Name" column.
    • Go to the Transform tab and click Group By.
    • Group by your newly mapped Master Name, and set the operation to Sum on the Sales Amount column.
    • Click Close & Apply to load your cleanly aggregated data back into an Excel sheet.

Method 2: Calculating Similarity Scores via VBA (Custom Formula)

If you need real-time calculations directly within your workbook cells without refreshing Power Query, you can use a custom VBA User-Defined Function (UDF) to calculate the Levenshtein Distance. This algorithm measures the minimum number of single-character edits required to change one word into another.

The VBA Code

Press ALT + F11 to open the VBA Editor, insert a new module, and paste the following code:

Function LevenshteinSimilarity(ByVal string1 As String, ByVal string2 As String) As Double
    Dim len1 As Integer, len2 As Integer
    Dim matrix() As Integer
    Dim i As Integer, j As Integer
    Dim cost As Integer
    
    string1 = LCase(Trim(string1))
    string2 = LCase(Trim(string2))
    
    len1 = Len(string1)
    len2 = Len(string2)
    
    If len1 = 0 Then
        LevenshteinSimilarity = IIf(len2 = 0, 1, 0)
        Exit Function
    End If
    If len2 = 0 Then
        LevenshteinSimilarity = 0
        Exit Function
    End If
    
    ReDim matrix(0 To len1, 0 To len2)
    
    For i = 0 To len1: matrix(i, 0) = i: Next i
    For j = 0 To len2: matrix(0, j) = j: Next j
    
    For i = 1 To len1
        For j = 1 To len2
            If Mid(string1, i, 1) = Mid(string2, j, 1) Then
                cost = 0
            Else
                cost = 1
            End If
            matrix(i, j) = Application.Min(matrix(i - 1, j) + 1, _
                                           matrix(i, j - 1) + 1, _
                                           matrix(i - 1, j - 1) + cost)
        Next j
    Next i
    
    ' Calculate percentage similarity
    Dim maxLen As Integer
    maxLen = IIf(len1 > len2, len1, len2)
    LevenshteinSimilarity = 1 - (matrix(len1, len2) / maxLen)
End Function

How to Use the Formula to Aggregate

Once the VBA module is saved, you can use =LevenshteinSimilarity(text1, text2) directly inside Excel cells to output a similarity score from 0 (completely different) to 1 (exact match).

To aggregate data based on this score, set up a helper column system:

  1. Step 1 (Helper Column): In your raw data table, assume your messy name is in cell A2 and your standard/master list starts in column E. Find the best match from your Master List using a dynamic array formula:
    =INDEX(MasterList, MATCH(MAX(LevenshteinSimilarity(A2, MasterList)), LevenshteinSimilarity(A2, MasterList), 0))
    Note: If you are not on Excel 365, you may need to enter this as an array formula using Ctrl+Shift+Enter.
  2. Step 2 (Aggregation): Once every raw name is assigned to its closest master name match via the helper column, write a standard SUMIFS formula to aggregate the values:
    =SUMIFS(Sales_Amount, Helper_Column_Mapped_Names, "Acme Corp")

Method 3: The Legacy Fuzzy Lookup Add-In

For users on older versions of Excel or those who prefer a dedicated wizard interface, Microsoft provides a free desktop add-in called the Fuzzy Lookup Add-In for Excel.

  • Download and install the add-in from Microsoft's official site.
  • Format your raw data and your master target data as official Excel Tables (Ctrl + T).
  • Go to the newly created Fuzzy Lookup tab on your Excel ribbon and click the Fuzzy Lookup button.
  • Configure the Left Table (Raw Data) and Right Table (Master Names), choose the join columns, and select the output columns, including the Similarity Score.
  • Set the similarity threshold slider. The add-in automatically generates an output table matching dirty rows to clean rows with their respective similarity scores. You can then run a pivot table over this mapped output to aggregate your numbers.

Best Practices for Fuzzy Match Aggregations

Regardless of the method you choose, matching text programmatically carries a risk of mismatches (false positives). To ensure your aggregated financials or reporting metrics remain precise, implement the following best practices:

  • Data Pre-Cleaning: Before running any fuzzy match, strip out punctuation (dots, commas, hyphens), remove extra spaces using the TRIM function, and convert everything to lowercase to optimize matching speeds and accuracy.
  • The 0.8 Threshold Rule: Standard industry practice is to start with a similarity threshold of 0.80. If you notice incorrect groupings (e.g., "Apple" matching "Maple"), increase it to 0.85 or 0.90. If matches are missed, drop it to 0.75.
  • Auditing Low Scores: When generating reports, isolate rows where the similarity score falls between 0.60 and 0.80. These are your "risk zones" that require manual review before finalizing aggregations.

Conclusion

Using raw strings to build reports is a recipe for incomplete metrics. By leveraging either Power Query's Fuzzy Merge for scalable automated pipelines or a Levenshtein VBA function for cell-based dynamic calculations, you can easily group similar items, assign accurate similarity scores, and calculate precise aggregate values across your entire dataset.

Disclaimer:
The documents and templates provided on this page are for informational and illustrative purposes only. They do not constitute professional, legal, or financial advice, and should not be relied upon as such. Because individual circumstances and regulatory requirements vary, these materials may not be suitable for your specific needs. We recommend consulting with a qualified professional before adapting or using any of these examples for official or commercial purposes.