How to Merge Two CSV Files on a Shared Column Without Writing SQL
Customer info in one file, order history in another, and you need them combined. Here's how to merge two CSV files on a shared key using VLOOKUP, Power Query, or a no-code merge tool — and how to avoid the mistakes that quietly drop or duplicate rows.
Real business data almost never lives in one tidy file. Customer records come from one export, order history from another, support tickets from a third system entirely. Getting useful analysis out of any of them individually is limited — the real insight usually lives in the combination, like "which customers with more than three support tickets also churned." That requires merging files on a shared column, and while the concept (a "join," in database terms) is simple, there are several specific ways it silently goes wrong in a spreadsheet context that are worth understanding before you trust the output.
What "merging on a shared column" actually means
Say you have two files. customers.csv has one row per customer, with columns CustomerID, Name, Region. orders.csv has one row per order, with columns OrderID, CustomerID, Amount, Date. The shared column is CustomerID — it exists in both files, and it's the thing that lets you connect a row in one file to the corresponding row (or rows) in the other.
Merging combines these into one dataset where each order row also carries its customer's name and region, without you having to manually copy that information across. This is exactly what a database JOIN does, and it's what VLOOKUP, INDEX/MATCH, Power Query merges, and dedicated merge tools are all fundamentally doing under the hood, just with different interfaces and different failure modes.
Method 1: VLOOKUP (simple, but fragile)
For a straightforward one-to-one lookup — pulling a customer's region into the orders file based on CustomerID — VLOOKUP is the fastest option:
=VLOOKUP(B2, customers!A:C, 3, FALSE)
This looks up the value in B2 (a CustomerID in the orders file) against the first column of the customers range, and returns the value from the third column (Region) of the matching row. The FALSE at the end matters — it forces an exact match rather than Excel's default "closest match" behavior, which produces silently wrong results far more often than people realize when left on its default setting.
VLOOKUP's real limitations show up at scale: it only looks up the first match it finds, so if CustomerID appears more than once in the customers file (which shouldn't happen, but often does thanks to the duplicate-row problems covered in our guide to removing duplicate rows), you'll silently get whichever row happens to be first, with no warning that other matching rows existed. It's also comparatively slow on large files, and it only ever looks rightward from the lookup column, which occasionally forces awkward column reordering just to make a lookup possible.
Method 2: Power Query (more powerful, steeper learning curve)
Excel's Power Query (Get & Transform Data) is built specifically for this kind of multi-file merge, and it handles the messier real-world cases much better than a formula can. You can merge two tables on one or more shared columns, choose the join type (more on that below), and — critically — it shows you the result as an actual combined table rather than a formula scattered across cells, which makes the output much easier to audit.
The tradeoff is a real learning curve: Power Query has its own interface, its own step-by-step transformation model, and enough depth that most casual spreadsheet users never fully learn it, even though it's included with Excel by default.
The join type decision that actually matters
Whichever tool you use, there's one decision that determines more about your result than anything else: what happens to rows that don't have a match on the other side?
Inner join — only keep rows that have a match in both files. A customer with no orders disappears from the result entirely; an order with a CustomerID that doesn't exist in the customer file also disappears. This silently drops data, which is usually not what you want unless you're deliberately looking only at customers who have placed at least one order.
Left join — keep every row from your primary file (say, orders), and pull in matching data from the second file where it exists, leaving blanks where it doesn't. This is the most common choice for "enrich this file with data from that file" use cases, because it preserves every row from the file you actually care about.
Full outer join — keep every row from both files, matched where possible, with blanks on either side where there's no corresponding row. Useful when you specifically need to audit which records exist in one file but not the other — for instance, finding customers with no orders and orders with no valid customer record, in the same pass.
Picking the wrong join type is the single most common way a merge silently produces a wrong-looking dataset — usually by dropping rows nobody meant to drop, via an inner join used where a left join was needed. If your merged row count looks suspiciously smaller than either source file, this is almost always the first thing to check.
The mistake that causes duplicate row explosions
If the shared key isn't actually unique in one of the files — for example, if orders.csv has multiple rows per CustomerID (which is completely normal; customers place multiple orders) and you merge in a way that treats it as one-to-one — you can end up with a row-count explosion, where each customer's info gets duplicated once per matching order row. This is usually correct behavior for a one-to-many relationship like customers-to-orders, but it's worth explicitly confirming that's the relationship you expect, rather than being surprised when your merged file has more rows than either source.
A no-code option for merging without formulas or Power Query
For a quick merge without building VLOOKUP formulas or learning Power Query's interface, DataForge's multi-dataset merging (available on the Premium plan) lets you upload up to three files at once and merge them based on shared column headers directly in your browser — no formulas, no SQL, and no file leaving your machine. It's aimed at exactly this "I have two or three related exports and need one combined dataset" case, without requiring you to first learn a query language or a formula-based join pattern to get there.
Before you trust the merged result
Regardless of which tool does the actual merge, run these checks afterward:
- Compare row counts against expectations. Does the result have roughly the number of rows you'd expect given the join type you chose?
- Spot-check a few known records. Pick a customer or order you know the correct answer for, and confirm the merged row matches.
- Check for unexpected blanks. A left join producing far more blanks than expected in the "enriched" columns usually means the shared key isn't formatted consistently between the two files — a
CustomerIDstored as text in one file and as a number in the other will fail to match despite looking identical, which is worth ruling out before you trust the result.
Merging two files on a shared column is conceptually simple and mechanically full of small ways to get a plausible-looking wrong answer. Choosing the right join type deliberately, and spot-checking the row count and a few known records afterward, is what separates a merge you can trust from one that just happens to look right at first glance.