Forum Discussion

beaoliv123-_'s avatar
beaoliv123-_
Icon for Helper I rankHelper I
3 years ago
Solved

Extract Last Numeric Characters and a "-"

Hi,   I'd like to extract the last 19 numerical characters that appear on a string of my data. These 19 characters can start with a "-" or not. So, if the "-" exists, I want to extract it too and t...
  • bolfri's avatar
    3 years ago

    Add custom column as following:

    List.First(
            List.RemoveNulls(
                List.Transform(
                    Text.Split([FullString],"_"),
                    each 
                        let x = try Number.FromText(_)
                        in if x[HasError] then null else _
                )
            )
        )

     

    Steps:

    1. Take FullString column and split it by _ into list

    2. For each item in the list try to convert it into number
    3. If transformations has error > give me null, else give me that value

    4. Remove all nulls

    5. Return fist item in the list