Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

How to delete all text apart from a specific string if this string is located at the beginning?

Hello

 

How to delete all text apart from a specific string if this string is located at the beginning?

 

E.g. in:

ASFASDF ASDFSF

Erase all text apart from ASF, only if ASF is at the beginning.

 

Thanks!

  • You could use something like this in a custom column

     

    = if Text.Start([TextColumn],3) = "ASF" then Text.Start([TextColumn],3) else [TextColumn]

     

    Pat

2 Replies

  • mahoneypat's avatar
    mahoneypat
    Icon for Microsoft Employee rankMicrosoft Employee

    You could use something like this in a custom column

     

    = if Text.Start([TextColumn],3) = "ASF" then Text.Start([TextColumn],3) else [TextColumn]

     

    Pat

  • Anonymous's avatar
    Anonymous
    Not applicable

    This way you don't have to count how many characters your key has 😁

    let
        TESTO="ASFYUTUYETJGHJ",
        START="ASF",
        Origine = if Text.StartsWith(TESTO,START) then START else TESTO
    in
        Origine