Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Column split by conditon

I have a requirement to extract/split data if value starts with P or QM to be 7 characters rest should be as-is, how it can be achived? help needed As-is PABCP01A CSOMTO04 PPQRX01M QM0888TA ATL...
  • ChrisMendoza's avatar
    ChrisMendoza
    7 years ago

    Anonymous -

    Are you meaning that you have so many conditions for Text.StartsWith = "P" || "QM" || etc.?

     

    If so, then you should include those requirements in your question.

     

    Otherwise, you just need to add the logic from the last statment 

    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Text.StartsWith([#"As-is"], "P") then Text.RemoveRange([#"As-is"],7) else if Text.StartsWith([#"As-is"],"QM") then Text.RemoveRange([#"As-is"],7) else [#"As-is"])