Forum Discussion

LoMorrissey's avatar
LoMorrissey
Regular Visitor
1 year ago
Solved

Extracting HTML Code from Power Bi

I am attempting to extract HTML text by creating a custom column but keep the rows with regular text at the same time. I have used this code to remove the HTML text but am missing the part where it k...
  • v-karpurapud's avatar
    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.