Price Duplicate Cleanup and Generate Test Contacts

By Andrew Apell, creator of Flookup Data Wrangler. Updated

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.

Key Takeaways

  • Each guide starts from a free method you can try in Google Sheets before you install anything, so the technique can be checked on your own data before it becomes part of a recurring workflow.
  • The Apps Script examples read and write the sheet once.
  • Formula alternatives cover the common case while the script handles the awkward edges that arrive with a real export.
  • Every example keeps its source columns.

Introduction

Two questions come up before any data cleanup begins. What is the problem worth, and how will we know the fix works? A cost model answers the first. A test file with a known number of duplicates answers the second.

This guide builds both in Google Sheets. A short formula estimates the cost of manual duplicate repair. A ready-made Apps Script generates fictional contacts with a chosen duplicate rate so you can test a deduplication rule against a known answer.


The Cost Model

Start with four inputs, each in its own cell.

InputExampleMeaning
Records50,000Total contacts in the system
Duplicate rate3%Share that need a merge decision
Minutes per merge4Average human time per pair
Hourly cost45Loaded cost of the person doing it

Multiply records by the rate to get the duplicate count. Multiply that by minutes and by the hourly cost divided by sixty to get the labour cost. The same shape works for any segment if you change the inputs.


The Ready-Made Apps Script

Open Extensions then Apps Script, paste the code below and run generateTestContacts(). It writes a sheet called Test Contacts with a header and the number of rows you set in the constants.

const ROW_COUNT = 200;
const DUPLICATE_RATE = 0.05;
const FIRST_NAMES = ["Marie", "Isaac", "Rosalind", "Alan", "Ada", "Grace", "Linus", "Barbara"];
const LAST_NAMES = ["Curie", "Newton", "Franklin", "Turing", "Lovelace", "Hopper", "Torvalds", "Liskov"];
const DOMAINS = ["zephyrion.com", "orbitra.co", "helixa.io", "northwind.test"];

function pick_(list, index) {
  return list[index % list.length];
}

/** Generates fictional contacts with a chosen share of near-duplicate rows. */
function generateTestContacts() {
  const rows = [["Name", "Email", "Phone", "Organisation"]];
  const used = [];
  for (let i = 0; i < ROW_COUNT; i += 1) {
    const duplicate = used.length > 0 && Math.random() < DUPLICATE_RATE;
    let row;
    if (duplicate) {
      const source = used[Math.floor(Math.random() * used.length)];
      row = [source[0].toUpperCase(), source[1], source[2], source[3]];
    } else {
      const first = pick_(FIRST_NAMES, i);
      const last = pick_(LAST_NAMES, Math.floor(i / FIRST_NAMES.length));
      const domain = pick_(DOMAINS, i);
      row = [
        first + " " + last,
        first.toLowerCase() + "." + last.toLowerCase() + "@" + domain,
        "+44 7700 " + String(100000 + i).slice(-6),
        last + " Ltd",
      ];
      used.push(row);
    }
    rows.push(row);
  }
  const book = SpreadsheetApp.getActiveSpreadsheet();
  let sheet = book.getSheetByName("Test Contacts");
  if (!sheet) {
    sheet = book.insertSheet("Test Contacts");
  }
  sheet.clearContents();
  sheet.getRange(1, 1, rows.length, 4).setValues(rows);
  console.log("Generated " + ROW_COUNT + " test contacts.");
}

The generator uses fixed word lists, so the output is repeatable apart from the rows chosen as duplicates. Change the word lists to match your domain if you want a more realistic file.

Set ROW_COUNT to the size you need and DUPLICATE_RATE to a value between zero and one. A rate of 0.05 means about five duplicate rows in every hundred.


A Worked Example

With 50,000 records, a 3 percent rate, four minutes per merge and a 45 hourly cost, the formula gives 1,500 duplicate records and 4,500 in manual labour. If a per-record CRM charge of 0.02 applies to each duplicate, add another 30 to the model.

MeasureValue
Expected duplicates1,500
Manual minutes6,000
Labour cost4,500
CRM charge, if applied30

Those figures are deliberately simple. The point is to make the cost visible before someone commits a team to a manual cleanup.


The Cost Formula

Put the four inputs in cells B1 to B4, then use:

=ROUND(B1*B2*B3*B4/60,0)

That returns the labour cost directly. To see the duplicate count first, use:

=ROUND(B1*B2,0)

Keep the inputs in cells rather than inside the formula. A model you can change in one place is a model someone else will trust.


Where the Model Stops

A duplication rate is an assumption until you measure it. Use a sample of the real file to estimate the rate before you put a number in a business case. The audit checklist shows how to take that sample.

The generated contacts are useful for testing mechanics, not for judging business value. They have no buying history, geography or intent, so a match that works on them still needs a trial on a real export.

Cost is not only labour. A duplicate record can trigger a wrong mailer or a bad report, which is why the hidden cost guide looks beyond the merge itself.


Price the Work, Then Test the Fix

A short model turns an argument about dirty data into a number. A generated test file turns a promised cleanup into something you can measure. Use both before you buy a tool or assign a team.

When the test file is ready, run your deduplication rule over it and count how many known duplicates it finds. Flookup Data Wrangler keeps the scored matches and the review step in the same sheet.


Frequently Asked Questions

What does the cost formula measure?

It combines record volume, a duplicate rate, manual merge time and an hourly rate into one expected cleanup cost. It is an estimate for a business case, not an invoice.

Can I include a per-record CRM charge?

Yes. Add it as another input cell and multiply it by the duplicate count in the same way as the labour cost.

Are the generated contacts real people?

No. Every name, email and phone number is assembled from fixed word lists. Nothing is scraped from a live source.

How does the duplicate rate work?

The generator reuses an earlier row for a chosen share of records and changes the case or whitespace, so a deduplication test sees a realistic near-duplicate.

Why generate test data at all?

It gives you a repeatable input for a cleanup workflow. You know the expected duplicate count, so you can measure whether a rule finds them all.


You Might Also Like