Table.SelectColumns
This function retrieves a table containing only the columns specified by the user. - Table: The table that the user wants to extract columns from. - Columns: A list of specific columns from the table...
Table.SelectColumns(table as table, columns as any, optional missingField as nullable number) as table
This function retrieves a table containing only the columns specified by the user.
- Table: The table that the user wants to extract columns from.
- Columns: A list of specific columns from the table that the user wants to include in the extracted table. The columns will appear in the same order as listed in the input.
- MissingField: (Optional) Indicates how to handle cases where a specified column does not exist in the table. Options include MissingField.UseNull or MissingField.Ignore.
Example 1
Include only the column named [Name].
Usage:
In Power Query M, use the MTable.SelectColumns function with the Table.FromRecords method to select the desired column.
Output:
The output will display the records containing only the [Name] column.
Example 2
Include columns [CustomerID] and [Name] only.
Usage:
Utilize Power Query M and the MTable.SelectColumns function with the Table.FromRecords method to specify the columns to be included.
Output:
The output will show the records with columns [CustomerID] and [Name].
Example 3
In case the specified column is not found, an error will be returned by default.
Usage:
When using Power Query M and the MTable.SelectColumns function, if the specified column does not exist in the dataset, an error will occur.
Output:
The output will display an error message stating that the specified column was not found.
Example 4
If the specified column is missing, the MissingField.UseNull option will create a column with null values.
Usage:
When using Power Query M and th