Back to Piggy in Google Sheets
SheetXAI logo
Piggy logo
Piggy · Google Sheets Guide

Merge Duplicate Loyalty Contacts in Bulk Using a Google Sheet

2026-05-14
5 min read

The Scenario

A data quality analyst on your team ran a deduplication audit on the Piggy loyalty database last month. She found 60 duplicate customer pairs — same person, two accounts, split loyalty history. The pairs are documented in a Google Sheet: source_uuid in column A, destination_uuid in column B. The task is to merge all 60 pairs so each customer ends up with one consolidated record.

The bad version:

  • Open Piggy, find the contact merge tool, search for the first source UUID, find the destination, initiate the merge, confirm.
  • Do that 60 times. Even at 2 minutes per merge, that's two hours of clicking.
  • Around merge 40, you accidentally select the wrong destination UUID and merge two unrelated customers. Now you have a support ticket, a credit balance discrepancy, and a rollback request.

The duplicates were identified with care. The merge itself should not require human attention at every step.

The Easy Way: One Prompt in SheetXAI

SheetXAI is an AI agent that lives inside your Google Sheet. It reads the source and destination UUID pairs, submits each merge to Piggy, and writes the result status back into column C — so you have a full audit log when it's done.

For each row in the 'DuplicatePairs' sheet (columns: source_uuid, destination_uuid), merge the source contact into the destination in Piggy and write the merge job status into column C

What You Get

  • Column C fills with the merge status for each pair — QUEUED, COMPLETED, or ERROR depending on what Piggy returns.
  • Rows where the merge failed (invalid UUID, contact already merged, API error) get a descriptive error in column C so you can investigate those specific pairs.
  • You have a permanent record of every merge submitted, with timestamps if Piggy returns them — useful for the audit trail if a customer later asks about their balance.
  • All 60 merges are submitted in one pass without manual intervention.

What If the Data Is Not Quite Ready

Some pairs might have already been merged — check before submitting

For each row in the 'DuplicatePairs' sheet, check whether the source UUID still exists as an active Piggy contact. If it does, submit the merge and write MERGED into column C. If the source is already gone, write ALREADY MERGED into column C and skip

The merge direction needs to be verified — you want the higher-balance account to be the destination

For each row in the 'DuplicatePairs' sheet, fetch the credit balance for both the source UUID (column A) and destination UUID (column B) from Piggy. If the source balance is higher, swap the merge direction. Submit the merge with the higher-balance account as the destination and write the actual source and destination used into columns D and E. Log the result into column C

Some destination UUIDs in the sheet contain typos — normalize before submitting

For each row in the 'DuplicatePairs' sheet, trim whitespace from columns A and B and validate that both values are in UUID format. Flag any malformed pairs in column C with INVALID FORMAT. For all valid pairs, submit the merge to Piggy and write the result into column C

Validate both UUIDs, check balances, submit merges in the right direction, and summarize

For each of the 60 pairs in the 'DuplicatePairs' sheet, validate that both UUIDs exist in Piggy. Fetch balances for each. Merge the lower-balance account into the higher-balance account. Write the merge direction used into column D, the result into column C, and the combined balance into column E. Write a summary in cell G1: total submitted, total completed, total errors

Running the balance check and direction logic inline means you never accidentally consolidate credits into the wrong account.

Try It

Open a Google Sheet with your duplicate UUID pairs and Get the 7-day free trial of SheetXAI. Ask it to submit all your Piggy contact merges and write a status log back into the sheet. For related workflows, see how to bulk create custom contact attributes or the full Piggy integration overview.

Stop memorizing formulas.
Tell your spreadsheet what to do.

Join 4,000+ professionals saving hours every week with SheetXAI.

Learn more