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.
you can define the following function and use it in your code
(inputText as text) as table =>
if Text.StartsWith(inputText, "<") then
Table.Combine({
Html.Table("<div>" & inputText & "</div>", {{"Final Decision Notes", "div"}}),
Html.Table("<div>" & inputText & "</div>", {{"Final Decision Notes", "br"}})
})
else
#table({"Final Decision Notes"}, {{ inputText }})