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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Siboska
Helper II
Helper II

HTML format to text in tables

Hi, 

I have some HTML columns in T-SQL that I'm importing into Power BI. I have created an HTML strip function in T-SQL that considers most of the signs. However, I cannot figure out how to keep the text formatting options such as bold (<strong>,</strong>). I have created a replace function that replaces "strong" with "b" as I thought Power BI was handling that as bold text. Unfortunately, it seems not to work. Does anyone have a suggestion for how I can obtain this?

(The HTML visual in Power Bi is not an option in this case)


Siboska_0-1681979775386.png

 

1 ACCEPTED SOLUTION

Hi @Siboska ,

 

According to my knowledge, Power BI won't retain information about fonts, bolding, etc. when fetching data from data sources.

If you want to change the format of your value, you could change the visual format:

vjianbolimsft_0-1683100277938.png

vjianbolimsft_1-1683100287523.png

Best Regards,

Jianbo Li

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

3 REPLIES 3
v-jianboli-msft
Community Support
Community Support

Hi @Siboska ,

 

Here is a handy M Function for stripping all the HTML tags:

 

let func = (HTML) =>
    let
        Check = if Value.Is(Value.FromText(HTML), type text) then HTML else "",
        Source = Text.From(Check),
        SplitAny = Text.SplitAny(Source,"<>"),
        ListAlternate = List.Alternate(SplitAny,1,1,1),
        ListSelect = List.Select(ListAlternate, each _<>""),
        TextCombine = Text.Combine(ListSelect, "")
    in
        TextCombine, 
        documentation = [
            Documentation.Name =  " Text.RemoveHtmlTags"
            , Documentation.Description = "Remove Html Tags"
            , Documentation.LongDescription = " Removes all Html tags from a text"
            , Documentation.Category = " Text.Modification"
            , Documentation.Source = " Inspired by a solution from Bill Szysz"
            , Documentation.Author = " Imke Feldmann: www.TheBIccountant.com & Mike Carlo: PowerBI.Tips"
            , Documentation.Examples = {[
                Description = "Function that enables one to pass in a column that has HTML tags."
                , Code = "<div>my bit of text</div>"
                , Result = "my bit of text "
                ]}] 
 in 
    Value.ReplaceType(func, Value.ReplaceMetadata(Value.Type(func), documentation))

 

Please try to create a new blank query and paste the above code into the advanced editor:

vjianbolimsft_0-1683020372872.png

 

Then you can use this function directly:

vjianbolimsft_1-1683020372876.png

 

Final output:

vjianbolimsft_0-1683020480240.png

 

Best Regards,

Jianbo Li

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

Hi Jianbo, 

Unfourtenly it doesn't respect the text format option like bold, italic e.g.

Siboska_0-1683095452361.png

 

Hi @Siboska ,

 

According to my knowledge, Power BI won't retain information about fonts, bolding, etc. when fetching data from data sources.

If you want to change the format of your value, you could change the visual format:

vjianbolimsft_0-1683100277938.png

vjianbolimsft_1-1683100287523.png

Best Regards,

Jianbo Li

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.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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