Forum Discussion

JNelson's avatar
JNelson
Helper II
2 years ago
Solved

Search column and group text

Hi all,   I need to create a measure or group (not a calculated column) to create a new Y/N measure based on names in a column. I've tried grouping the names but there are thousands of names in my ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi JNelson ,

     

    The CONTAINSSTRING function is designed to handle individual strings, not columns or tables directly.

     

    When using measure, you need to make sure that the function iterates through each row of the table to check the condition for each name.

     

    If you want to learn more about the CONTAINSSTRING function, please see:

    CONTAINSSTRING function (DAX) - DAX | Microsoft Learn

     

    Please follow these steps:

     

    1. This is the original data I created:

     

    2. Please try:

    IsInTeam1 = 
    CALCULATE(
        IF(
            COUNTROWS(
                FILTER(
                    Teams,
                    CONTAINSSTRING(Teams[Name], "Joe Bloggs") || 
                    CONTAINSSTRING(Teams[Name], "Jane Smith") || 
                    CONTAINSSTRING(Teams[Name], "Bob Thompson")
                )
            ) > 0, 
            "Y", 
            "N"
        )
    )
    

     

    3. Drag data to the report page for display:

     

    pbix file is attached.

     

    If you have any further questions, please feel free to contact me.

     

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!