Search code examples
powerbipowerquery

Remove Alphanumeric string and following character from end of the string in power BI


I want to remove alphanumeric string and all the following characters from the end of a string in column in power bi

example 1: Input /Chill/chill/batch/design/961057df-7a86-4159-a532-f6919175f478/version

Output /Chill/chill/batch/design

example 2: Input /Chill/chill/batch/design/961057df-7a86-4159-a532-f6919175f478

Output /Chill/chill/batch/design


Solution

  • = Table.AddColumn(Source, "Custom", each [a=Text.Start([Input],Text.PositionOfAny([Input],{"0".."9"})),
    b=Text.PositionOf(a,"/",Occurrence.Last),
    c=Text.Start(a,b)
    ][c])
    

    enter image description here

    = Table.AddColumn(Source, "Custom", each [a=Text.PositionOfAny([Input],{"0".."9"}),
    b=Text.Start([Input],a),
    c=Text.PositionOf(b,"/",Occurrence.Last),
    d=Text.Start(b,c),
    e= if a=-1 then [Input] else d
    ][e])
    

    enter image description here