Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Custom Column to extract STRING

Hi Experts   How would you extract all data from column Work Type that has in the string of text the letter ABC and or BCD anywhere in the string...into a new column and all other entries are blank...
  • Stachu's avatar
    8 years ago

    try this PowerQuery code, apply it in Add Column>Custom Column window

    [
    abc = Text.PositionOf([Work Type],"ABC"),
    bcd = Text.PositionOf([Work Type],"BCD"),
    resultABC = if abc <> -1 then Text.Middle([Work Type],abc,3) else null,
    resultBCD = if bcd <> -1 then Text.Middle([Work Type],bcd,3) else null,
    result = Text.Combine({resultABC, resultBCD})
    ][result]