Table.ToColumns Function in Power Query

The Table.ToColumns returns a list of nested lists each representing a column of values in the input table.

Syntax

Table.ToColumns(table as table) as list

Example: Create a list of the column values from the table.

Power Query M

let
  MyTable = Table.FromRecords(
    {
      [CustomerID = 1, Name = "Ashish", Phone = "123-4567"], 
      [CustomerID = 2, Name = "Katrina", Phone = "987-6543"], 
      [CustomerID = 3, Name = "Alia", Phone = "543-7890"], 
      [CustomerID = 4, Name = "Vicky", Phone = "676-8479"], 
      [CustomerID = 5, Name = "Mohini", Phone = "574-8864"], 
      [CustomerID = 6, Name = "Meenakshi", Phone = "574-8864"], 
      [CustomerID = 7, Name = "Esha", Phone = "574-8864"], 
      [CustomerID = 8, Name = "Anjali", Phone = "574-8864"]
    }
  ), 
  Return = Table.ToColumns(MyTable)
in
  Return  

The output of the above code is shown below:

Table.ToColumns in Power Query

In the code form it looks like,

{
    {1, 2, 3, 4, 5, 6, 7, 8},
    {"Ashish", "Katrina", "Alia", "Vicky", "Mohini", "Meenakshi", "Esha", "Anjali"},
    {"123-4567", "987-6543", "543-7890", "676-8479", "574-8864", "574-8864", "574-8864", "574-8864"}
}

We can see that it is a list of nested lists.

Example: Return the Name column values as list.

Power Query M

let
  MyTable = Table.FromRecords(
    {
      [CustomerID = 1, Name = "Ashish", Phone = "123-4567"], 
      [CustomerID = 2, Name = "Katrina", Phone = "987-6543"], 
      [CustomerID = 3, Name = "Alia", Phone = "543-7890"], 
      [CustomerID = 4, Name = "Vicky", Phone = "676-8479"], 
      [CustomerID = 5, Name = "Mohini", Phone = "574-8864"], 
      [CustomerID = 6, Name = "Meenakshi", Phone = "574-8864"], 
      [CustomerID = 7, Name = "Esha", Phone = "574-8864"], 
      [CustomerID = 8, Name = "Anjali", Phone = "574-8864"]
    }
  ), 
  Return = Table.ToColumns(MyTable){1}
in
  Return 

The output of the above code is shown below:

Table.ToColumns in Power Query