Forum Discussion

OneWithQuestion's avatar
OneWithQuestion
Post Prodigy
3 years ago

Split column by delimiter each occurrence - RIGHT to left?

I'm processing a folder directory, but it is stored from RIGHT to left instead of the more normal "left" to right.

Normally I'd split column be delimiter and do "each occurence of the delimiter", but I need to process it RIGHT to left.

Is there a way to do each occurance but read right to left instead of left to right?

Thank you!

3 Replies

  • Hello - you can reverse the text, apply the split, and then reverse the text back.

    Table.TransformColumns(#"Your Previous Step Here",{{"Folder Path", Text.Reverse, type text}})
    • OneWithQuestion's avatar
      OneWithQuestion
      Post Prodigy

      I was playing with the reverse idea, but I think I would have to apply it to each specific column that comes out of the split.

      So when I do the split it makes 8 columns.

      I reversed the source column, did the split, and that worked great!

      Then I have 8 columns, but I have to apply the reverse again to each individual column.

      I was trying to figure out how to reverse the output of the split itself???


      #"Added Custom" = Table.AddColumn(#"Duplicated Column1", "Custom", each Text.Reverse([FolderPath])),
      #"Split Column by Delimiter1" = Table.SplitColumn(#"Added Custom", "Custom", Splitter.SplitTextByDelimiter(",", QuoteStyle.None), {"Custom.1", "Custom.2", "Custom.3", "Custom.4", "Custom.5", "Custom.6", "Custom.7", "Custom.8"}),
      #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Custom.1", type text}, {"Custom.2", type text}, {"Custom.3", type text}, {"Custom.4", type text}, {"Custom.5", type text}, {"Custom.6", type text}, {"Custom.7", type text}, {"Custom.8", type text}})


      Is there a way to reverse the results returned by the Splitter before it makes each of the 8 columns so I can avoid calling a Text.Reverse on each column as a last step?

  • Anonymous's avatar
    Anonymous
    Not applicable

    You could still split by delimiter, and then if you can combine those columns into a list of text (I'm not at my computer, you'll figure it out :), you can use List.Reverse to put the split text into the right order.

     

    You could also just Split, Transpose, then Table.Reverse.

     

    --Nate