Forum Discussion

ValeriaBreve's avatar
ValeriaBreve
Post Partisan
2 years ago
Solved

String substraction from another string

Hello, I have a table as per below:   Main Category Category 2 Final A Apples=Pears Pears,Raisin,Apple Raisin B Red Yellow,Green,Red Yellow,Green C Seven=Five=Six One,Two,Th...
  • dufoq3's avatar
    2 years ago

    Hi ValeriaBreve, you made a mistake probably, so I've edited your sample data a bit

     

    Result

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("HYq7CoAwFEP/5c75hQ4q6Kioi5QOggELpZWKj8/32iUh58RaqQRSHUegGbjmU1dpjKs/fURR4mClVjVy01wYQnrQZTLiR79uVEy8GU3rb5rJvwr6SMxPwrzrF226MspHnPsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Main = _t, Category = _t, #"Category 2" = _t]),
        Ad_Final = Table.AddColumn(Source, "Final", each 
            [ a = Text.Split([Category], "="),
              b = Splitter.SplitTextByAnyDelimiter(a)([Category 2]),
              c = Text.Combine(List.Select(List.Transform(b, (x)=> Text.Trim(x, {" ", ","})), (y)=> not List.Contains({"", null},y)))
            ][c], type text)
    in
        Ad_Final