In the M language documentation for Table.TransformRows, it lists the type signature as Table.TransformRows(table as table, transform as function) as list
followed by the slightly cryptic comment
If the return type of the transform function is specified, then the result will be a table with that row type.
However, whenever I define my function, Power Query always returns me a list instead of a table. For instance, this query:
func = (row) as record => [B = Number.ToText(row[a])] as record,
#"firstTable"= Table.FromRecords({
[a = 1],
[a = 2],
[a = 3],
[a = 4],
[a = 5]}),
#"myTable" = Table.TransformRows(#"firstTable",func)
in
#"myTable"
returns a table. I had wondered if I needed to create a record type which specifies the type of each record entry, but if I try
myType = type [B = text],
func = (row) as record => [B = Number.ToText(row[a])] as myType
then it tells me that my type identifier is invalid on the second line. Finally, I tried to set the function return type using
myType = type [B = text],
func1 = (row) as record => [B = Number.ToText(row[a])] as myType,
funcType = Type.ForFunction([ReturnType = myType, Parameters = [X = type number]], 1),
func = Value.ReplaceType(func1,funcType)
but Table.TransformRows still returns a list.
I am aware that I am able to use Table.FromRecords or Table.FromRows to turn the result of Table.TransformRows into a table, but I am currently experiencing some performance issues with these functions and was trying to cut them out to see if this would fix those issues