List.Zip Function in Power Query
The List.Zip function take a list of lists and returns a list of lists combining items at the same position.
Syntax
List.Zip(lists as list) as list
Example: Zips the two lists.
Power Query M
let Source = ({{"Ashish", "Alia"}, {"Haryana", "Mumbai"}}), return = List.Zip(Source) in return
The output of the above code is shown below:
Output
{ {"Ashish", "Haryana"}, {" Alia", "Mumbai"} }
Example:
Power Query M
let MyTable = Table.FromRecords( { [CustomerID = 1, Name = "Ashish", Phone = "123-4567", Company = "TCS"], [CustomerID = 2, Name = "Katrina", Phone = "987-6543", Company = "Microsoft"], [CustomerID = 3, Name = "Alia", Phone = "543-7890", Company = "Infosys"], [CustomerID = 4, Name = "Vicky", Phone = "676-8479", Company = "Capgemini"], [CustomerID = 5, Name = "Mohini", Phone = "574-8864", Company = "Google"], [CustomerID = 6, Name = "Meenakshi", Phone = "574-8864", Company = "TCS"], [CustomerID = 7, Name = "Esha", Phone = "574-8864", Company = "TCS"], [CustomerID = 8, Name = "Anjali", Phone = "574-8864", Company = "Accenture"] } ), return = List.Zip({MyTable[Name], MyTable[Company]}) in return
The output of the above code is shown below:
Output
{ {"Ashish", "TCS"}, {"Katrina", "Microsoft"}, {"Alia", "Infosys"}, {"Vicky", "Capgemini"}, {"Mohini", "Google"}, {"Meenakshi", "TCS"}, {"Esha", "TCS"}, {"Anjali", "Accenture"} }