Entity Resolution for Data Reconciliation

By Andrew Apell, creator of Flookup Data Wrangler. Updated

Key Takeaways

  • Entity resolution links rows across two exports that share no identifier, by combining a block key, a similarity score and a recorded decision.
  • In the sample below, four postcode blocks reduce sixteen possible comparisons (4 times 4) to four candidate pairs.
  • Suffix words such as Corp and Limited depress a character score, so remove them before scoring rather than lowering the threshold.
  • A phonetic variant such as John Smith against Jon Smyth still needs a human review.

You can link orders to CRM rows across two exports that share no identifier, with a score and a decision for each pair.

StepExact formula
Normalise a name=LOWER(TRIM(REGEXREPLACE(A2, "[^A-Za-z0-9 ]", "")))
Block on postcode=UPPER(LEFT(SUBSTITUTE(B2, " ", ""), 3))
Score a pair=SIMPERCENT(Orders!D2, CRM!D2)

What you should see: four candidate pairs, raw scores of 1.00, 0.80, 0.67 and 0.60, and three accepted pairs after suffix removal.


What You Will Build

You have an orders export and a CRM export. Neither contains a shared customer ID. By the end of this page you will have a canonical table that pairs each order row with the correct CRM row, shows the score behind every decision and flags the one pair that needs a person to look at it.

All formulas are typed into a blank sheet. The score function is a short Apps Script you paste once. Nothing in the example requires a paid add-on.


The Two Source Tables

Sheet Orders holds the paid orders and sheet CRM holds the customer records. Names and postcodes differ between the two systems.

Orders nameOrders postcodeOrder ID
Acme CorpSW1A 1AA1042
John SmithEC1A 1BB1043
Northwind TradersW1A 1HQ1044
Globex LtdN1 9GU1045
CRM nameCRM postcodeCRM ID
ACME CorporationSW1A 1ABC-88
Jon SmythEC1A 1BCC-91
Northwind Trader LimitedW1A 1HRC-104
GlobexN1 9GVC-120

Step 1, Normalise With a Formula

Put both name columns into the same form before comparing them. In cell D2 of each sheet enter:

=LOWER(TRIM(REGEXREPLACE(A2, "[^A-Za-z0-9 ]", "")))

Fill the formula down. The formula lowercases the value, removes punctuation and collapses stray spaces. The four order names become acme corp, john smith, northwind traders and globex ltd. The CRM names become acme corporation, jon smyth, northwind trader limited and globex.

Without this step, case and punctuation alone would change every score and the thresholds would need to be far looser.


Step 2, Block on a Postcode Key

Comparing four rows against four rows is trivial, but ten thousand against ten thousand is one hundred million pairs. A block key is a short shared value that limits which pairs you compare. Here the key is the first three non space characters of the postcode, entered in column E:

=UPPER(LEFT(SUBSTITUTE(B2, " ", ""), 3))

The result for both sheets is SW1, EC1, W1A and N19. A pair is a candidate only when both rows carry the same key. That produces four candidate pairs instead of sixteen, and the reduction grows sharply with list size.

Choose a block key that survives ordinary data entry error. Postcode prefixes, the first letter of a surname and a date month are common choices. A full name is a poor key because the variations you want to catch will change it.


Step 3, Score the Pairs

Open Extensions, Apps Script, paste the function below, save it and return to the sheet. It implements the standard Levenshtein edit distance and returns a score from 0 to 1.

/**
 * Returns Levenshtein similarity between two values.
 * @param {string} a The first normalised name.
 * @param {string} b The second normalised name.
 * @returns {number} A score from 0 to 1.
 */
function SIMPERCENT(a, b) {
  const x = String(a).toLowerCase().trim();
  const y = String(b).toLowerCase().trim();
  if (x === y) return 1;
  const row = Array.from({ length: y.length + 1 }, (_, j) => j);
  for (let i = 1; i <= x.length; i++) {
    let prev = row[0];
    row[0] = i;
    for (let j = 1; j <= y.length; j++) {
      const old = row[j];
      const cost = x[i - 1] === y[j - 1] ? 0 : 1;
      row[j] = Math.min(row[j] + 1, row[j - 1] + 1, prev + cost);
      prev = old;
    }
  }
  const distance = row[y.length];
  const longer = Math.max(x.length, y.length);
  return longer === 0 ? 1 : 1 - distance / longer;
}

In a review sheet, enter =SIMPERCENT(Orders!D2, CRM!D2) for each of the four blocked pairs. The scores are exact outputs of the function above:

Blocked pairNormalised valuesScore
1042 against C-88acme corp / acme corporation0.56
1043 against C-91john smith / jon smyth0.80
1044 against C-104northwind traders / northwind trader limited0.67
1045 against C-120globex ltd / globex0.60

These scores are low because the differences are whole words rather than single typos. A threshold is the score a pair must reach before you accept it, and lowering it to accept these pairs would also accept unrelated rows. The next step removes that noise before scoring again.


Step 4, Remove Suffix Noise and Rescore

Build a suffix column with a substitution chain, then strip the known suffix from both sides. In column F enter:

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(D2, " corporation", ""), " limited", ""), " corp", ""), " ltd", "")

Apply the same four substitutions to the CRM names. The values that reach the scorer now become:

PairAfter suffix removalNew scoreDecision
1042 against C-88acme / acme1.00Accept
1043 against C-91john smith / jon smyth0.80Review
1044 against C-104northwind traders / northwind trader0.94Accept after checking the trailing s
1045 against C-120globex / globex1.00Accept

Three pairs now clear 0.90. The remaining pair is a spelling variant rather than a typo, and no edit-distance threshold will join john to jon without also admitting unrelated names. Send that pair to a phonetic check or a person.


Step 5, Write a Review Sheet

Create a tab called Reconciliation with one row per accepted or flagged pair and these columns: order ID, CRM ID, block key, score before suffix removal, score after suffix removal, decision and reviewer. Keep both scores so a later audit can see why a threshold choice changed.

The canonical customer table then takes the CRM ID as its stable key and fills missing fields from the order row. Never use a name as the key. Names are exactly the field that produced the four different spellings in this example.

On a larger file, wrap the score call in a filter on the block key so you only score pairs inside the same block. That single change turns a quadratic job into a linear one.

The Reconciliation rows from this example are:

Order IDCRM IDBlock keyScore beforeScore afterDecision
1042C-88SW10.561.00Accept
1043C-91EC10.800.80Review
1044C-104W1A0.670.94Accept after check
1045C-120N190.601.00Accept

Frequently Asked Questions

What is entity resolution in Google Sheets?

Entity resolution is the task of deciding whether two rows from different exports describe the same real person, company or product. The worked example links an order export to a CRM export using a postcode block key and a Levenshtein similarity score, because the two files share no common identifier.

How is entity resolution different from deduplication?

Deduplication collapses repeated rows inside one list. Entity resolution links rows across two lists and keeps a record of which source row contributed each field. Both stages appear in the worked example: the score decides the link and the canonical table records the source identifiers.

Why do I need a blocking key?

A blocking key limits comparisons to plausible pairs. In the example the first three characters of the postcode group four order rows with four CRM rows into four candidate pairs instead of sixteen. The score is then computed only inside each block.

What score should I accept automatically?

On the sample data, pairs scoring 1.00 after suffix removal are safe to accept and the pair scoring 0.94 needs a quick check of the trailing s. The pair scoring 0.80 is a phonetic variant and goes to manual review. Set the cut-offs from a labelled sample rather than copying these numbers.


You Might Also Like

About the Author

Andrew Apell is the creator of Flookup Data Wrangler and has built data cleaning tools for Google Sheets since 2018.
Every Flookup result described here can be checked in the documentation.
Read Our Story for the background or contact the team with any questions about this post, including corrections, unclear steps or use cases we have not covered yet.