Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Re: Editing rows in a column

If I have figures like

  1. AS 1,2,3,4
    2. AS 1,3,4
    And I want to extract only those where 2 appears and put it in a different column, how can I do that?

  • Hey Anonymous ,

     

    in addition to the solution amitchandak already provided here is another one that is a little more detailed. Here the text 1,2,3,4 will be converted into a list, then the list items will be checked if one is 2. This prevents that a list item like 12 will being tested positive.
    You can use this snippet inside the Power Query Custom Column dialog:

    if List.Contains(
    Text.Split( [else] , "," ) , "2" )
    then "contains 2"
    else "does not contain 2"

    A screenshot:

    And the result:


    Hopefully, this provides what you are looking for.

    Regards,

    Tom

2 Replies

  • Anonymous ,

    In a new column power query

    if Text.Contains([Column], "2") then [Column] else null

     

    in DAX, a new column

     

    if(Containsstring([Column], "2") ,[Column] ,blank())

  • Hey Anonymous ,

     

    in addition to the solution amitchandak already provided here is another one that is a little more detailed. Here the text 1,2,3,4 will be converted into a list, then the list items will be checked if one is 2. This prevents that a list item like 12 will being tested positive.
    You can use this snippet inside the Power Query Custom Column dialog:

    if List.Contains(
    Text.Split( [else] , "," ) , "2" )
    then "contains 2"
    else "does not contain 2"

    A screenshot:

    And the result:


    Hopefully, this provides what you are looking for.

    Regards,

    Tom