Table.TranformColumnNames()主要用于批量修改表格字段名称,该函数可抽象为function( table as table, nameGenerator as function, Optional options as nullable record) as table。第一个参数是只能是表格类型的变量,第二个参数可以理解为以字段名称为自变量的某函数结果。第三个参数不一定要填,如有需要只能以记录形式进行填写,主要用来控制字段最大字符数以及比较规则。

情景一:以上为表格Employee,字段名称以表格名称开头紧跟着带中括号的字段描述,现在需要把字段名称中的表格名称以及中括号去掉,达到这个效果的M语言代码为:
= Table.TransformColumnNames( Empolyee, each Text.BetweenDelimiters( _, "[", "]" ) )

情景二:把表格Employee的所有字段的小写字母改为大写字母,以下为现实这个目的的M语言代码:
= Table.TransformColumnNames( Empolyee, each Text.Upper( _ ) )

情景三:如果仅需要保留中括号以及其中的内容,可以使用以下M语言代码:
= Table.TransformColumnNames( Empolyee, each Replacer.ReplaceText( _, "Employee", "" ) )
