powerbi - Power BI - Remove all HTML tags in one column - Stack Overflow

admin2025-04-28  3

I have a Power BI dataset with one column that contains HTML tags. I have tried to make a custom column with the following code:

try Html.Table([HTML Text],{{"PlainText",":root"}}) otherwise null

However, when I do this the values from the original column are all over the place. Some rows which did not contain any text, now do and vice versa. Am I doing something wrong? It is important that the values remain in their original rows if that makes sense. So I would like to exclude the HTML tags from my column while keeping the text in the right rows.

Below is an example:

<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri, sans-serif;color:#1F497D;">Allen,</span></p><p class="ql-align-justify"></p>

<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri, sans-serif;color:#1F497D;"></span></p><p class="ql-align-justify"> </p>

<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri, sans-serif;color:#1F497D;">Zie onder het antwoord van </span></p><p class="ql-align-justify"></p>

<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri, sans-serif;color:#1F497D;">Het antwoord lijkt mij afdoende zo, tenzij jullie nog aanvullende vragen of opmerkingen hebben?</span></p><p class="ql-align-justify"></p>

I have a Power BI dataset with one column that contains HTML tags. I have tried to make a custom column with the following code:

try Html.Table([HTML Text],{{"PlainText",":root"}}) otherwise null

However, when I do this the values from the original column are all over the place. Some rows which did not contain any text, now do and vice versa. Am I doing something wrong? It is important that the values remain in their original rows if that makes sense. So I would like to exclude the HTML tags from my column while keeping the text in the right rows.

Below is an example:

<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri, sans-serif;color:#1F497D;">Allen,</span></p><p class="ql-align-justify"></p>

<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri, sans-serif;color:#1F497D;"></span></p><p class="ql-align-justify"> </p>

<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri, sans-serif;color:#1F497D;">Zie onder het antwoord van </span></p><p class="ql-align-justify"></p>

<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri, sans-serif;color:#1F497D;">Het antwoord lijkt mij afdoende zo, tenzij jullie nog aanvullende vragen of opmerkingen hebben?</span></p><p class="ql-align-justify"></p>

Share Improve this question edited Jan 9 at 12:58 Sam Nseir 12.5k2 gold badges5 silver badges21 bronze badges asked Jan 9 at 12:56 MagdalenaMagdalena 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

I'm not sure why that happened for you. Did the rows mess up directly at this step or another step further down?

Try updating your Custom Column to:

try Html.Table([HTML Text], {{"PlainText",":root"}}){0}[PlainText] otherwise null

Or to this one if you want to remove excess whitespace:

try Text.Clean(Html.Table([HTML Text], {{"PlainText",":root"}}){0}[PlainText]) otherwise null
转载请注明原文地址:http://anycun.com/QandA/1745800109a91226.html