Forum Discussion

MHTANK's avatar
MHTANK
Helper III
2 years ago
Solved

Split column as per specific condition

This is my data:

I want this result:

  •  Explanation :

When Y= no bgm then X column split as per result(2nd photo), only split by one character, where the last character is "B" or "Y"

  • Hi MHTANK 

    In Power Query, create a custom column and paste the below code 

     

    = if [Y]="no bgm" then Text.Start([X],1) else [X]

     


    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

4 Replies

  • PijushRoy's avatar
    PijushRoy
    Community Champion

    Hi MHTANK 

    In Power Query, create a custom column and paste the below code 

     

    = if [Y]="no bgm" then Text.Start([X],1) else [X]

     


    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

    • MHTANK's avatar
      MHTANK
      Helper III

      Oh, it's very easy, thank you so much 👍🏻

  • PijushRoy's avatar
    PijushRoy
    Community Champion

    Hi MHTANK 

    With DAX, create a calculated column and paste the code

     

    Z = IF('Table'[Y]="no bgm",LEFT('Table'[X],1),'Table'[X])

     


    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