Forum Discussion

JonPT's avatar
JonPT
Regular Visitor
1 year ago
Solved

Extract Alphanumeric Value from String

Hi Power BI Desktop Forum I'm trying to extract an 8-character alphanumeric value from a column in Power BI desktop. The pattern to extract is: first 2 characters are lower case a-z, followed by an...
  • Kaviraj11's avatar
    1 year ago

    Hi,

     

    Create a custom column  as below

     

    = let
    Source = [String],
    Pattern = List.First(List.Select(List.Transform({0..Text.Length(Source)-8}, each Text.Middle(Source, _, 8)), each Text.Length(_) = 8 and Text.Middle(_, 0, 2) = Text.Select(Text.Middle(_, 0, 2), {"a".."z"}) and Text.Middle(_, 2, 6) = Text.Select(Text.Middle(_, 2, 6), {"0".."9"})))
    in
    if Pattern = null then null else Pattern