Forum Discussion

CareLess's avatar
CareLess
Copper Contributor
Jul 09, 2020
Solved

Powerquery keep just substring

Hey all,   I Have records with a string that can have 1 ore more substring in surrounded by brackets. I just want those substrings, the rest i want to toss. Any handy tips or functions i can use?...
  • SergeiBaklan's avatar
    SergeiBaklan
    Jul 11, 2020

    CareLess 

    Perhaps I misunderstood your requirements, initial code returns only very internal string. 

    If all substrings are to be returned, you may

    1) Use almost UI only solutions - split using variant of splitter with Any, list delimiters {"{","}"} and with some gap on number of columns; unpivot all columns of the result

     

    2) Use formula which splits all texts into the lists and expand them

    let
        Source = Table1,
        splitTexts = Table.AddColumn(
            Source,
            "Custom",
            each List.RemoveMatchingItems(Text.SplitAny([A],"{}"),{""})
        ),
        expandSubstrings = Table.ExpandListColumn(
            splitTexts,
            "Custom")
    in
        expandSubstrings

     

    3) Use Imke's function which do practically the same, but is more universal solution

     

    All 3 variants are in attached file.

Resources