Forum Discussion

joxe's avatar
joxe
Regular Visitor
5 years ago
Solved

How to divide a column keeping the delimiter?

Hello,

When I divide a column by delimiter in the result the delimiter is lost. How can I keep it?

Thanks.

  • Anonymous's avatar
    Anonymous
    5 years ago

    You could use ReplaceValues and replace "<h3" with "<h3,", and then split using "," as the delimiter.
    --Nate

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    You could use ReplaceValues and replace "<h3" with "<h3,", and then split using "," as the delimiter.
    --Nate

    • joxe's avatar
      joxe
      Regular Visitor

      Very easy and very effective solution. Thank you very much!

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi joxe 

     

    Can you provide some sample data and expected result? Not sure what exactly you want...split it by delimiter then add it back?

     

     

    • joxe's avatar
      joxe
      Regular Visitor

      Hi Vera,

      I am working with the code of a web page. I need to split a column into rows each time the <h3 text appears, which usually goes in a sequence: <h3 class = "article__title">. Therefore:

       

       

      But after the step I lose the delimiter and, as you can see, each row starts with class = "article__title", and not wiht <h3 class = "article__title">, as I need:

       

       

      Do you know how to keep the delimiter?

       

      Thank you very much.

       

  • joxe's avatar
    joxe
    Regular Visitor

    Hi Anonymous again,

     

    In my answer I did not show the formula, which maybe helps:

     

    = Table.ExpandListColumn(Table.TransformColumns(#"Converted to Table", {{"Column1", Splitter.SplitTextByDelimiter("<h3", QuoteStyle.None), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Column1")

     

     

     

    I compare it with the formula of your image, and I can't figure out how to adapt it.

     

    Best regards,