Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

How to extract ID numbers from a text string?

Hi, @ImkeF @Zubair_Muhammad Now I’m trying to solve a slightly more complex situation. I’m trying to extract the 5 and 6 length ID numbers for UK and France. This is my current approach...
  • Zubair_Muhammad's avatar
    7 years ago

    Anonymous

     

    Try this. I am not 100% sure.

    Please could you paste data in copiable format instead if image

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCvXWL0tMTsxLrtS3NDQyMrPX003NLcjJr0xNVYrViVZyC3LUBwtkFqcUJ6YkGpkYx5QaGBin6jtYGIKAia6evlJsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Page = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Page", type text}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Text.Start([Page],2)="UK" then
                                                                        Text.BetweenDelimiters([Page],"/", "?",1)
                                                                        else
                                                                        if Text.Start([Page],3)="FRA"
                                                                        then
                                                                        Text.BetweenDelimiters([Page],"@", "-")
                                                                        else
                                                                        null)
        in
        #"Added Custom"