Table.TransformColumnNames is a Power Query M function that transforms column names by using the given nameGenerator function and additional options like MaxLength and Comparer. The function returns a table with transformed column names based on the provided parameters.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Table.TransformColumnNames(
table as table,
nameGenerator as function,
optional options as nullable record,
) as table
Description
Transforms column names by using the given nameGenerator
function. Valid options:
MaxLength
specifies the maximum length of new column names. If the given function results with a longer column name, the long name will be trimmed.
Comparer
is used to control the comparison while generating new column names. Comparers can be used to provide case-insensitive or culture and locale-aware comparisons.
Comparer.Ordinal
: Used to perform an exact ordinal comparisonComparer.OrdinalIgnoreCase
: Used to perform an exact ordinal case-insensitive comparison-
Comparer.FromCulture
: Used to perform a culture-aware comparison
Examples
Remove the #( tab )
character from column names
// Output: Table.FromRecords( {[Column = 1]} )
Table.TransformColumnNames( Table.FromRecords( {[#"Col#( tab )umn" = 1]} ), Text.Clean )
Transform column names to generate case-insensitive names of length 6.
// Output: Table.FromRecords( {[Column = 1, cOlum1 = 2, coLum2 = 3]} )
Table.TransformColumnNames(
Table.FromRecords( {[ColumnNum = 1, cOlumnnum = 2, coLumnNUM = 3]} ),
Text.Clean,
[MaxLength = 6, Comparer = Comparer.OrdinalIgnoreCase]
)
Related articles
Learn more about Table.TransformColumnNames in the following articles:
- Transform Column Names in Bulk in Power Query
This post provides techniques for efficiently renaming columns in bulk, covering both basic and advanced transformations to support your data cleaning process. » Read more
Related functions
Other functions related to Table.TransformColumnNames are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy