Forum Discussion
sardo
2 years agoRegular Visitor
Convert HTML column to plain/formatted text in Power BI
I need to conver HTML column in plain text. I've watched some tutorials and added a custom column with the following coding in Power Query: Html.Table([HTML text],{{"Plain text",":root"}}) This does...
Sahir_Maharaj
2 years agoSuper User
Hello sardo,
Can you please try the following:
1. Before converting HTML to text, you should replace or remove null values to prevent errors during the conversion process (Use the "Replace Values" in Power Query)
2. Extract text from the HTML using M code
let
HtmlToText = (html as text) as text =>
let
// Replace HTML tags with empty strings
Step1 = Text.Replace(html, "<", " <"),
Step2 = Text.Split(Step1, "<"),
Step3 = List.Transform(Step2, each if Text.StartsWith(_, "/") or Text.Contains(_, ">") then "" else _),
TextResult = Text.Trim(Text.Combine(Step3, ""))
in
TextResult
in
HtmlToText
3. Use the custom function you've defined by referencing your HTML column: HtmlToText([YourHtmlColumnName])
Note: If your conversion results in a table, you might need to expand it. Hope this helps.
sardo
2 years agoRegular Visitor
Hi Sahir,
Thank you so much for your response.
Can you please guide me where can I add that code in the "Replace Values" in Power Query?