Forum Discussion
Melinda_Newbie
2 years agoNew Member
Loop through table and replace values within text from another table
I’m new to Power BI so pardon my question, but I’m wondering if there is a way to do the following: I have a SQL table with a column that is HTML that contains something like below. Not all HTML is...
- 2 years ago
Hi Melinda_Newbie ,
yes, this should be possible:// PA Data let Source = Excel.CurrentWorkbook(){[Name="HTML"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"Clause Text", type text}}), #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"ID"}, #"Child Var", {"ParentID"}, "Child Var", JoinKind.LeftOuter), #"Added Custom" = Table.AddColumn(#"Merged Queries", "Result", each List.Accumulate(List.Buffer(Table.ToRecords([Child Var])), [Clause Text], (state,current)=> if current[VariableID] = null then state else Text.Replace(state, "[pp_" & current[VariableID] & "_pp]", current[VariableValue]))), #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Child Var"}) in #"Removed Columns"
ImkeF
2 years agoCommunity Champion
Hi Melinda_Newbie ,
it transforms the table "tags" into a list of records.
Did you see that my answer included a file as well?
This should make it easier for you to follow the solution, I hope.
Melinda_Newbie
2 years agoNew Member
Yes, I saw the attachment, but have no idea what you are doing there. The tags are already in a list, so I'm not sure why or how you would need to create another one? Sorry, I know I've got a lot to learn.