Table.SelectColumns Function in Power Query
The Table.SelectColumns function returns a table that contains only specific columns from the given table, which are specified in the function.
Syntax
Table.SelectColumns(table as table, columns as any, optional missingField as nullable number) as table
The function has the following parameters:
• table: The provided table.
• columns: The list of columns from the table to return. Columns in the returned table are in the order listed in columns.
• missingField: It is an optional parameter. It specifies what to do if the column does not exist.
Example: Only include column "Name" from the given 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.SelectColumns(MyTable, "Name") in Return
The output of the above formula is shown below:
