Hi, I'm trying to create a function that will rename all columns in a table., but when I invoke the function (from both the query editor and navigation panel) I get the folliwng error:
An error occurred in the ‘fnRenameColumns’ query. Expression.Error: We cannot convert a value of type Record to type Number.
Details:
Value=Record
Type=Type
The function is:
let fnRenameColumns = (tableName as table) => let Source = tableName, ColumnNames = Table.FromList(Table.ColumnNames(Source)), Transform = Table.AddColumn(ColumnNames,"New Value",each Text.Upper(Text.Replace([Column1],"_"," "))), RenameColumns = Table.RenameColumns(tableName,Table.ToRows(Transform),[Comparer = Comparer.OrdinalIgnoreCase]) in RenameColumns in fnRenameColumns
Any ideas? Thanks!