Hi @RIVERA Nicole (Genuent)
Thanks for posting your code. Your problem is with List.Accumulate's seed (2nd) argument and the fact that you always refer to the same table (tbl). The following works here:
let
// Function begin
fxRenameMulti_If = (tbl as table, lt as list) as table =>
let
Source = tbl,
RenamedColumns = List.Accumulate({0..List.Count(lt)-1}, Source,
(State, Current)=>
Table.RenameColumns(State,
List.Transform(Table.ColumnNames(State), each
{_, if Text.Contains(_, lt{Current}{0}) then lt{Current}{1} else _}
)
)
)
in
RenamedColumns,
// Function end
Source = Table.FromRows(
{List.TransformMany({1..5}, each {"demo"}, (x,y)=> y & Text.From(x))},
{"Year","Per","GL Account","Post","Cost element name"}
),
RenamedMulti = fxRenameMulti_If(Source,
{{"GL","GL Acc#"},{"Post","Post Date"},{"Coat","Cost Element"},{"Year","Year 2021"}}
)
in
RenamedMulti