Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello all,
Can you please help with below.
I am trying to get below code to work but I keep getting error Token Comma expected. I have checked other discussions and the error seems to be regarding the "[counter] +1] " in line 0008.
Appreciate any help.
Regards Tommy
(x as text) as text =>
let
maxIterations = Table.RowCount(BulkTextReplace),
Iterations = List.Generate( () =>
[Result=Text.Replace(x, BulkTextReplace[Old Value]{0}, BulktextReplace[Replace]{0}), Counter = 0],
each [Counter] < maxIterations,
each [Result = Text.Replace([Result], BulkTextReplace([Result], BulkTextReplace[Old Value]{Counter}, BulkTextReplace[Replace]{Counter}),
Counter = [Counter]+1], each [Result]),
output = Iterations(maxIterations-1)
in
output
Hi, @TCpowerbi , you might want to try a direct call to List.Accumulate() to accomplish the same task,
List.Accumulate(
Table.ToRecords(BulktextReplace),
str,
(s,c) => Text.Replace(s, Text.From(c[Old Value]), Text.From(c[Replace]))
)
| Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Hi @TCpowerbi
There was some incorrect syntax and a few issues with brackets, you were missing the closing ) for List.Generate.
In addition you had 4 parameters for the second call to Text.Replace but it only takes 3.
This is syntactically correct but may not do what you were intending.
You are using List.Generate to build a list made of the values in Result, but you are trying to create an output value from Iterations(maxiterations -1) ?
(x as text) as text =>
let
maxIterations = Table.RowCount(BulkTextReplace),
Iterations = List.Generate
(
() =>
[Result=Text.Replace(x, BulkTextReplace[Old Value]{0}, BulktextReplace[Replace]{0}), Counter = 0],
each [Counter] < maxIterations,
each [Result = Text.Replace([Result], BulkTextReplace[Old Value]{Counter}, BulkTextReplace[Replace]{Counter}), Counter = [Counter]+1],
each [Result]
)
in
Iterations
Phil
Proud to be a Super User!
I can't debug it from this side. It looks like the square brackets are used too liberally and not in pairs.
Go through it line by line.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.