List.Zip
Pairs up items from several lists by position, so the first items go together, then the second items, and so on.
List.Zip(lists)Returns: A list of lists, one inner list per position.
What it does
List.Zip takes several lists of the same length and builds rows out of them: the first item of each list forms the first row, the second items form the second row, and so on. It is the list version of placing two columns side by side. Use it when you have labels in one list and amounts in another and want them paired.
Syntax and arguments
lists: a list of lists. Each inner list should have the same number of items. Shorter lists are padded with nulls.
Example
A budget owner has the twelve month names in one list and the budgeted amounts in another. The report needs each month next to its amount.
let
Months = {"Jan", "Feb", "Mar"},
Budget = {12000, 12500, 11800},
Pairs = List.Zip({Months, Budget}),
FirstRow = Pairs{0}
in
Pairs
Pairs is {{"Jan", 12000}, {"Feb", 12500}, {"Mar", 11800}}. Each inner list is one row. FirstRow would be {"Jan", 12000}, because lists count from zero.
Example: a second, different use
Turning the pairs into a table: Table.FromRows(Pairs, {"Month", "Budget"}) gives a two-column table ready to load.
Things to watch
- The lists are matched by position, not by value. Sort both lists the same way before you zip them, or the pairs will be wrong without any error message.
- A list shorter than the others is filled with nulls. Check the counts first with List.Count.
- If you already have a table, you rarely need to zip, because the columns are already paired.
- Position matching is fragile when a list is filtered in one place and not in another.
In business terms
Pairing labels with values from separate exports, lining up budget and actual columns from different files, and building a quick two-column check are the common uses. Always confirm the counts match, because a pairing error does not show up as an error.