Forum Discussion

ZachUnger's avatar
ZachUnger
Helper II
2 years ago
Solved

Extract multiple text

Hi Team 

 

I'm wondering if there is an easy way to extract anything starting with CRC or PE into a new column as per the picture below. 

Please note: some have multiple so I would need all of these possibly separated by a comma. 

Any help appreciated 

Cheers 

Z

  • Hi ZachUnger 

    In Power Query Editor, please create a custom column and use below code

    Text.Combine(List.Select(Text.Split([#"PE (comments)"], " "), each Text.StartsWith(_, "CRC") or Text.StartsWith(_, "PE")), ", ")

     

     

    If your requirement is solved, please make sure to MARK AS SOLUTION ✔️ and help other users find the solution quickly. Please hit the LIKE 👍 button if this comment helps you.

    Thanks
    Pijush
    www.MyAccountingTricks.com 
    https://www.youtube.com/MyAccountingTricks

     

4 Replies

  • PijushRoy's avatar
    PijushRoy
    Community Champion

    Hi ZachUnger 

    In Power Query Editor, please create a custom column and use below code

    Text.Combine(List.Select(Text.Split([#"PE (comments)"], " "), each Text.StartsWith(_, "CRC") or Text.StartsWith(_, "PE")), ", ")

     

     

    If your requirement is solved, please make sure to MARK AS SOLUTION ✔️ and help other users find the solution quickly. Please hit the LIKE 👍 button if this comment helps you.

    Thanks
    Pijush
    www.MyAccountingTricks.com 
    https://www.youtube.com/MyAccountingTricks

     

  • Hi ZachUnger ,

    Please post a sample data that can be copy-pasted to Excel (not an image). Questions:

    1. Are PE and CRC case-sensitive?
    2. What if there are mutiple words that begin with those text strings? Say, two PEs and one CRC in one cell.
    3. Are the results going to be in the same row or each match has its own row?