Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
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.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |