Power Query List.Union: How to Combine Lists
In this article
List.Union combines two or more lists into a single list and removes duplicates automatically. In Power Query (the data transformation engine in Excel and Power BI), you call it as List.Union({list1, list2, ...}) — the argument is a list of lists. The result contains every distinct value from all input lists, in the order each value first appears. Nothing needs to be installed; Power Query is built into Excel 2016 and later (Data > Get & Transform) and into Power BI Desktop. The only prerequisite is that you have at least two lists to combine and that you know whether you want duplicates removed (List.Union) or kept (List.Combine).
What You'll Need
- Excel 2016 or later with Power Query, or Power BI Desktop (the Power Query Editor is included in both).
- Two or more lists — these can come from table columns, manually typed lists, or the output of other Power Query functions.
- Basic familiarity with the Power Query Editor: the formula bar, the Advanced Editor, and how to add a custom step.
Step-by-Step
- Open the Power Query Editor. In Excel, select your data and go to Data > Get & Transform Data > From Table/Range. In Power BI Desktop, use Home > Transform Data. Menu labels can differ slightly by version and region, but the Editor itself is the same.
- Decide where your lists live. If you already have two columns or two queries whose values you want to merge, you can reference them directly. If not, you can create lists inline with
#listor by converting a column withTable.Column. For example,Table.Column(MyTable, "Names")returns the Names column as a list. - Add a custom step. In the Power Query Editor, go to Home > Advanced Editor to edit the M code directly, or use Add Column > Custom Column if you want the result as a new column. The Advanced Editor is the most reliable place to write a List.Union expression because it lets you name intermediate lists.
- Write the List.Union expression. The syntax is
List.Union({list1, list2}). For example:
The result islet List1 = {"apple", "banana", "cherry"}, List2 = {"banana", "date", "apple"}, Combined = List.Union({List1, List2}) in Combined{"apple", "banana", "cherry", "date"}— duplicates removed, first-seen order preserved. - Confirm the output. Click Done in the Advanced Editor. Power Query shows the resulting list in the preview pane. If you need the result as a table, wrap it with
Table.FromList(Combined, Splitter.SplitByNothing())and then expand the column. - Load or close & apply. In Excel, choose Close & Load to send the result to a worksheet or the Data Model. In Power BI, choose Close & Apply to commit the query.
Common Mistakes
- Passing lists as separate arguments.
List.Union(list1, list2)is wrong. The function takes a single argument: a list of lists, writtenList.Union({list1, list2}). - Expecting duplicates to be kept. List.Union removes duplicates by design. If you need every occurrence, use
List.Combine({list1, list2})instead. - Mixing data types. If one list contains numbers and another contains text, the union may fail or coerce values unexpectedly. Convert both lists to the same type first with
List.TransformorValue.FromText. - Assuming order is sorted. List.Union preserves first-seen order, not alphabetical order. Add
List.Sortif you need sorting. - Forgetting that lists are case-sensitive. "Apple" and "apple" are treated as different values. Normalize case with
Text.Lowerbefore unioning if that matters.
Tips
- Use
List.Unionwhen you want a clean, distinct set of values; useList.Combinewhen you want to concatenate and keep everything. - You can union more than two lists at once:
List.Union({a, b, c, d}). - If your lists come from table columns, wrap the column reference in
Table.Columnand pass the results into List.Union in one step. - To debug, preview each list separately in the Advanced Editor by returning it as the final expression before combining.
- For very large lists, List.Union is generally efficient, but if performance matters, filter duplicates out of each source query first to reduce the volume before unioning.
Troubleshooting
- "We cannot convert a value of type List to type Text" or similar type errors: one of your inputs is not a list. Check that each item inside the outer
{ }is itself a list, not a single value. - The result contains duplicates: you likely used
List.Combineinstead ofList.Union, or your values differ by case or whitespace. Trim and lowercase values first. - Empty result: confirm the lists are not empty and that the expression is the final step in your
letblock. An empty list unioned with anything returns the non-empty values, so an empty result usually means all inputs were empty. - Preview shows an error but the expression looks right: click the error cell to see the message, then simplify by testing one list at a time in the Advanced Editor.
- Changes not appearing in Excel or Power BI: use Close & Load (Excel) or Close & Apply (Power BI) to commit the query, then refresh.
Frequently Asked Questions
What is the difference between List.Union and List.Combine?
List.Union merges lists and removes duplicates. List.Combine merges lists and keeps every value, including repeats.
Does List.Union sort the result?
No. It preserves the order in which each distinct value first appears. Wrap the result in List.Sort if you need alphabetical or numeric order.
Can I union more than two lists?
Yes. Pass a single list containing all the lists you want to merge: List.Union({list1, list2, list3}).
Is List.Union case-sensitive?
Yes. "Apple" and "apple" are treated as distinct values. Normalize case with Text.Lower or Text.Upper before unioning if you want them merged.
Can I use List.Union on table columns?
Yes. Convert each column to a list with Table.Column(TableName, "ColumnName"), then pass those lists into List.Union.
Why does my List.Union return an error about a list of lists?
The function expects one argument that is a list of lists. If you pass separate arguments or a flat list of values, you will get a type error. Wrap your inputs in an extra pair of braces: List.Union({list1, list2}).