List.Zip
ListTransposes a list of lists, combining the Nth elements of each list into new inner lists.
Syntax
List.Zip(lists as list) as listParameters
| Name | Type | Required | Description |
|---|---|---|---|
lists | list | Yes | A list of lists to zip together. |
Return Value
list — A list of lists where each inner list contains the Nth element from each of the input lists.
Remarks
List.Zip transposes a list of lists, combining elements at the same index position from each input list into new inner lists. Given {{a1, a2, a3}, {b1, b2, b3}}, it returns {{a1, b1}, {a2, b2}, {a3, b3}}. This is the same as a matrix transpose operation and is analogous to Python's zip() function.
The output length equals the length of the shortest input list — extra elements from longer lists are silently dropped. If any input list is empty, the result is an empty list. Applying List.Zip twice on a rectangular (equal-length) list of lists returns the original arrangement.
The most common use of List.Zip is pairing a list of items with their index positions via List.Positions, enabling index-aware transformations. It is also used to combine parallel data columns from separate lists, or to build rows for Table.FromRows from positionally-aligned column lists.
Examples
Example 1: Zip two lists into pairs
List.Zip({{1, 2, 3}, {"A", "B", "C"}})Result | |
|---|---|
| 1 | {{1, A}, {2, B}, {3, C}} |
Example 2: Pair items with their index positions
let
Items = {"Alpha", "Beta", "Gamma"},
Indexed = List.Zip({List.Positions(Items), Items})
in
IndexedThe final output — a list of three pairs, each containing an index and its corresponding item.
Result | |
|---|---|
| 1 | {{0, Alpha}, {1, Beta}, {2, Gamma}} |
Example 3: Zip three lists (transpose a matrix)
List.Zip({{1, 2, 3}, {4, 5, 6}, {7, 8, 9}})Result | |
|---|---|
| 1 | {{1, 4, 7}, {2, 5, 8}, {3, 6, 9}} |
Example 4: Convert zipped pairs to a table
let
Keys = {"Name", "Age", "City"},
Values = {"Alice", 30, "Seattle"},
Zipped = List.Zip({Keys, Values}),
AsTable = Table.FromRows({Values}, Keys)
in
AsTableThe final output — a one-row table with columns Name, Age, and City populated from the Values list.
Name | Age | City | |
|---|---|---|---|
| 1 | Alice | 30 | Seattle |