Forum Discussion
Extracting HTML Code from Power Bi
- 1 year ago
Hi LoMorrissey
Welcome to the Microsoft Fabric Community Forum.
The issue observed in Power BI, involving the extraction of HTML content while retaining plain text rows, is primarily due to inconsistencies in the conditional logic used within the custom column formula. The current implementation utilizes Html.Table to parse HTML content when the text begins with an HTML tag indicator (such as <), but fails to maintain a consistent output structure for rows containing plain text. This discrepancy can lead to schema misalignment during data transformation.
To address this, it is recommended to ensure that both HTML and non-HTML rows are returned in a uniform table format. This can be achieved by wrapping plain text rows in a table structure that mirrors the output of the HTML parsing logic.
= if Text.StartsWith([Final Decision Notes], "<") then Table.Combine({ Html.Table("<div>" & [Final Decision Notes] & "</div>", {{"Final Decision Notes", "div"}}), Html.Table("<div>" & [Final Decision Notes] & "</div>", {{"Final Decision Notes", "br"}}) }) else #table({"Final Decision Notes"}, {{ [Final Decision Notes] }})For reference:
Html.Table - PowerQuery M | Microsoft Learn
Thank you for being part of Fabric Community Forum.
Regards,
Karpurapu D,
Microsoft Fabric Community Support Team.
Hi LoMorrissey
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If your issue resolved, kindly mark the helpful response and accept it as the solution to assist other community members in resolving similar issues more efficiently. If not, please provide detailed information so we can better assist you.
Hi,
I asked one of my colleagues and he was able to give me this code which solved the issue:
#"Added Custom" = Table.AddColumn( #"Replaced Value24" , "Custom", each if [Review Team Notes] = null or not Text.Contains([Review Team Notes], "<") then
"<p>" & [Review Team Notes] & "</p>"
else
[Review Team Notes]),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each if [Custom] <> null then
Html.Table([Custom], {{"text", ":root"}})
else
[Custom]),
#"Expanded Custom.1" = Table.ExpandTableColumn(#"Added Custom1", "Custom.1", {"text"}, {"Custom.1.text"}),
#"Removed Columns" = Table.RemoveColumns(#"Expanded Custom.1",{"Review Team Notes", "Custom"}),
#"Renamed Columns12" = Table.RenameColumns(#"Removed Columns",{{"Custom.1.text", "Review Team Notes"}}),
#"Changed Type2" = Table.TransformColumnTypes(#"Renamed Columns12",{{"Review Team Notes", type text}})
in
#"Changed Type2"
- v-karpurapud1 year agoCommunity Support
Hi LoMorrissey
We are glad to hear that you identified the cause and resolved the issue. Thank you for providing the details here. Please mark your insights as 'Accept as solution' so others with similar issues can find it easily.
Thank you.