Forum Discussion
ianbruckner
7 years agoFrequent Visitor
Remove text between html tags
I'm looking for help to remove html tags from a string. Example input: <div class="ExternalClass742C332E0D0340C598BC9A78413A04DE">Staff going to storage training</div> Desired output: Staff goin...
- 7 years ago
You could try using PowerQuery Text Between function and use '>' and '</' as the delimiters.
You can also do this in DAX using PATHITEM and SUBSTITUTE.
InnerHTML =
PATHITEM( // Splits the string using delimiter "|", and takes the 2nd item that is a type of Text
SUBSTITUTE( // Output <div class="Whatever"|Staff going to storage training|div>
SUBSTITUTE([Html], ">", "|"), // Output <div class="Whatever"|Staff going to storage training</div>
"</","|"
),
2,
TEXT
)
JoelDoesPBI
3 years agoNew Member
I know I am a little late to the game but after trying extract between '>' and '</' and having it not work for me I broke it down into 2 steps.
1. Extract before '</'
2. Extract after '<' (using the Scan for the delimiter from the end of the input' in advanced options)
This worked for me as my source text has an inconsistant number of HTML Tags but always more than 3. This meant Extract between was giving weird results.
#"Extracted Text Before Delimiter" = Table.TransformColumns(#"Changed Type", {{"Subject Request", each Text.BeforeDelimiter(_, "</"), type text}}),
#"Extracted Text After Delimiter" = Table.TransformColumns(#"Extracted Text Before Delimiter", {{"Subject Request", each Text.AfterDelimiter(_, ">", {0, RelativePosition.FromEnd}), type text}})