Forum Discussion

tmyasoutov's avatar
tmyasoutov
Frequent Visitor
3 years ago
Solved

How to extract/clean up numbers from column value. Same column!

Hey everyone!   One column in Power Query has two types of values:     A 73 digit and a 8 digit values. End result must be 8 digit, 10016711 and 10016709. How to extract or clean up the 73...
  • dcrosseto's avatar
    3 years ago

    Thanks for the info, here is my suggestion for the output, would love to see others alternatives.

    test is the column name I was trying

    steps

    1. checking if string starts with "PO"
    2. if True I do two RemoveRange, one for removing the first 4 chars "PO: "
    3. second the rest of the chars after the 8th number of what you want
    4. i use the Lenght to get numbers of string subtracting the "PO: 12345678" 

    I created a Custom Column on PowerQuery, but you can also add this directly on Source

     

    if Text.StartsWith([test], "PO") 
       then Text.RemoveRange(
                 (Text.RemoveRange(Text.From([test]),0,4)),
                 8, Text.Length([test])-12
                 )
    else [test]

     

    Please check if works, hope it was helpful.

    Regards,

    Douglas.