Forum Discussion

silverdale9999's avatar
6 years ago
Solved

Split Large Text Field

Not so much of a defined question, more of a "does anyone have any ideas I could try" kind of thing.

 

One of our business processes utilises a large text field within a ticketing system. (Rather than the more obvious use of actual system fields.. but anyway). I can't change this process - tried, but it's embedded across a lot of teams and it's a no go area. So to use one of my "favourite" corporate expressions.. "we are where we are".

 

This text field has around 20 different "fields" within it. Each one denoted by a number the start.. eg:

 

20_Who is the approver for this work

22_Who is implementing this work

 

They all follow this format, so the actual splitting of the columns is ok-ish - I've used this in my PowerQuery:

 

 = Table.SplitColumn(#"Removed Blank Rows", "Notes", 
 Splitter.SplitTextByAnyDelimiter({"1_","2_","3_","4_","5_","6_" etc

 

This may not be the most elegant, but it works and gets me a bunch of columns that can be renamed, and text that can be cleaned up.

 

The issue I'm having, is when new "fields" are added to the wall of text. If they're added at the end, fine. I just need to amend my query and add to the number of columns to split out.

 

When they are added in the middle though, it causes issues as what was Column B, now becomes Column C, and the new data is added to Column B, giving me a mix of different data in the same column.

 

This data is loaded in it's entirety again every day from the source system via a spreadsheet loaded onto sharepoint.

 

One thought I had was to split the query.. so load data up to a certain date with 'Query A'. Then, after the notes field has changed, use 'Query B' that will follow slightly different rules for the split, then append B to A once done.

 

Not sure this is the best approach though, so if anyone has any other suggestions (apart from get a new job) I'd be really appreciative.

 

If there is a better approach than using the split columns I'm happy to try it, not set on any particular way.

 

Thanks!!

  • v-zhenbw-msft's avatar
    v-zhenbw-msft
    6 years ago

    Hi silverdale9999 ,

     

    We need to split the cell into rows first.

    Select Note column and split it.

     

     

    The remaining steps are the same as the reply above.

    The result like this,

     

     

    If you have any question, please kindly ask here and we will try to resolve it.

     

    Best regards,

     

    Community Support Team _ zhenbw

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

     

    BTW, pbix as attached.

7 Replies

  • mahoneypat's avatar
    mahoneypat
    Microsoft Employee

    Can you provide a few rows of example or mock data, and what your desired output would look like?  I'm sure there is an easier way but your scenario is a little unclear.  For example, why not just split by "-" instead of the list "1_", "2_", etc.?

     

    If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

    Regards,

    Pat

    • silverdale9999's avatar
      silverdale9999
      Helper I

      Thanks for the reply!

       

      I originally was using the underscore to split, but then it became clear that some of the information contained within the fields also contains an underscore so it was causing quite a lot of "false" splits.

       

      Some more info:

       

      Example text:

       

      4_ Describe the risks
      <None>
      5 _ Will this cause an outage
      <Y>
      6_What is the impact
      <No Impact>
      8_ Can this be regressed?
      <Y>
      20_Who is the approver for this work
      <Joe Smith>
      22_Who is implementing this work
      <Joe Smith>

       

      This should split to:

       

      4_ Describe the risks5 _ Will this cause an outage6_What is the impact8_ Can this be regressed?20_Who is the approver for this work22_Who is implementing this work
      NoneYNo ImpactYJoe SmithJoe Smith

       

      This works fine, in the current format.

       

      The issue arises when the format of the notes field is changed.  EG, adding question 7 in bold below:

       

      4_ Describe the risks
      <None>
      5 _ Will this cause an outage
      <Y>
      6_What is the impact
      <No Impact>
      7_External Impact?
      <N>
      8_ Can this be regressed?
      <Y>
      20_Who is the approver for this work
      <Joe Smith>
      22_Who is implementing this work
      <Joe Smith>

       

      This results in the following.. The original format loads fine, but the new format does not - data is inserted into the wrong column, and data is missed off the end.

       

      4_ Describe the risks5 _ Will this cause an outage6_What is the impact8_ Can this be regressed?20_Who is the approver for this work22_Who is implementing this work
      NoneYNo ImpactYJoe SmithJoe Smith
      NoneYNo ImpactNYJoe Smithv

       

      I need to find a way to keep the text with it's question.. but I can't figure out where to start!

       

      Thanks

       

       

       

      • v-zhenbw-msft's avatar
        v-zhenbw-msft
        Community Support

        Hi silverdale9999 ,

         

        We can use the following steps in Power Query Editor to meet your requirement.

         

        1. Add a conditional column, if it doesn’t contain “_”, then it will show null.

         

         

        2. Then add a conditional column, if it contains “_”, then it will show null.

         

         

        3. We fill down the custom column. And filter the custom.1 is not null.

         

         

        4. At last we removed the column1, and transposed the Table.

         

         

        If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

         

        Best regards,

         

        Community Support Team _ zhenbw

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

         

        BTW, pbix as attached.