Forum Discussion

Goodkat's avatar
Goodkat
Icon for Helper II rankHelper II
7 months ago
Solved

Cache Text.Split / List Select line for multiple evaluation

Dear Power Query Enthusiasts, Last night I had an idea how to improve some text string cleaning and editing. I do split a string with SplitAny to enable for multiple delimiters, then check if the ...
  • jgeddes's avatar
    jgeddes
    7 months ago

    Is this along the lines of what you are looking for?

    SplitAndCombine =   
    Table.AddColumn(
        Quelle, 
        "Test", 
        each
            let 
                codeBlock = List.Buffer(List.Select(Text.SplitAny([hea], " _"), each _ <> ""))
            in 
                if List.Contains({"id", "key", "number"}, List.Last( codeBlock ), Comparer.OrdinalIgnoreCase) = true and List.Count( codeBlock ) > 1 then
                    Text.Combine( List.RemoveLastN( codeBlock, 1 ), " ")
                else
                    [hea]
    )