Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
nicksutherland
Frequent Visitor

Power Query and Partial HTML Fields

I'm running into a strange issue with some of the data I'm importing from a web app. The data is plain text in the web app, but sometimes it is coming in with the html tags. I am trying to remove the html tags, and I have tried using delimiters but this removes any data that doesn't have the html tags. I have also tried converting the data from html to plain text, but since it's not actually html and is already plain text this will not work. I'm wondering if anyone has any ideas on how to do this? I have inlcuded a sample of the data below.

 

nicksutherland_0-1671040567567.png

 

1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi @nicksutherland ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1671085604406.png

(2) Copy and paste the following code into Advanced Editor. This is achieved by splitting and merging columns.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiik1MDBOTsksAzNSjQyMjHQNLIDIqqICIqcPl8Sq1lzXyBKLWqVYHRyGG5FguDEew1MScwsUEktTMksU8lJTU4oVSvIVkoBSsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Project Memo" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Project Memo", type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Project Memo", Splitter.SplitTextByDelimiter("<div>", QuoteStyle.Csv), {"Project Memo.1", "Project Memo.2", "Project Memo.3"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Project Memo.1", type text}, {"Project Memo.2", type text}, {"Project Memo.3", type text}}),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Changed Type1", "Project Memo.2", Splitter.SplitTextByDelimiter("</div>", QuoteStyle.Csv), {"Project Memo.2.1", "Project Memo.2.2"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Project Memo.2.1", type text}, {"Project Memo.2.2", type text}}),
    #"Split Column by Delimiter2" = Table.SplitColumn(#"Changed Type2", "Project Memo.3", Splitter.SplitTextByDelimiter("</div>", QuoteStyle.Csv), {"Project Memo.3.1", "Project Memo.3.2"}),
    #"Changed Type3" = Table.TransformColumnTypes(#"Split Column by Delimiter2",{{"Project Memo.3.1", type text}, {"Project Memo.3.2", type text}}),
    #"Merged Columns" = Table.CombineColumns(#"Changed Type3",{"Project Memo.1", "Project Memo.2.1", "Project Memo.3.1"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged"),
    #"Removed Other Columns" = Table.SelectColumns(#"Merged Columns",{"Merged"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Other Columns",{{"Merged", "Project Memo"}})
in
    #"Renamed Columns"

(3) Then the result is as follows.

vtangjiemsft_1-1671085835355.png

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

1 REPLY 1
v-tangjie-msft
Community Support
Community Support

Hi @nicksutherland ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1671085604406.png

(2) Copy and paste the following code into Advanced Editor. This is achieved by splitting and merging columns.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiik1MDBOTsksAzNSjQyMjHQNLIDIqqICIqcPl8Sq1lzXyBKLWqVYHRyGG5FguDEew1MScwsUEktTMksU8lJTU4oVSvIVkoBSsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Project Memo" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Project Memo", type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Project Memo", Splitter.SplitTextByDelimiter("<div>", QuoteStyle.Csv), {"Project Memo.1", "Project Memo.2", "Project Memo.3"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Project Memo.1", type text}, {"Project Memo.2", type text}, {"Project Memo.3", type text}}),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Changed Type1", "Project Memo.2", Splitter.SplitTextByDelimiter("</div>", QuoteStyle.Csv), {"Project Memo.2.1", "Project Memo.2.2"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Project Memo.2.1", type text}, {"Project Memo.2.2", type text}}),
    #"Split Column by Delimiter2" = Table.SplitColumn(#"Changed Type2", "Project Memo.3", Splitter.SplitTextByDelimiter("</div>", QuoteStyle.Csv), {"Project Memo.3.1", "Project Memo.3.2"}),
    #"Changed Type3" = Table.TransformColumnTypes(#"Split Column by Delimiter2",{{"Project Memo.3.1", type text}, {"Project Memo.3.2", type text}}),
    #"Merged Columns" = Table.CombineColumns(#"Changed Type3",{"Project Memo.1", "Project Memo.2.1", "Project Memo.3.1"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged"),
    #"Removed Other Columns" = Table.SelectColumns(#"Merged Columns",{"Merged"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Other Columns",{{"Merged", "Project Memo"}})
in
    #"Renamed Columns"

(3) Then the result is as follows.

vtangjiemsft_1-1671085835355.png

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.