Forum Discussion
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 data set and I would have to scroll forever to add new people to the group.
Essentially, I have a table called Teams and want to search the Name column for specified members and return Y/N
IsInTeam1 = IF(CONTAINSSTRING(Teams[Name] in {"Joe Bloggs", "Jane Smith", "Bob Thompson"}),"Y","N")
I want it as a measure so it's easy enough for my colleague to add/remove a name in the formula bar when something changes.
I am having an issue as when I use the CONTAINSSTRING function I don't get the option to add my table/column?
I feel like this should be a simple one but can't get my head around it!
TIA
- Anonymous2 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 TeamIf 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!
2 Replies
- shravanreddy133Helper I
Hi,
Instead of measure, create a column through transform data with multiple IF conditions.
for Example :
MemberPresence = IF(
OR( CONTAINSSTRING(Teams[Name], "Member1"),
CONTAINSSTRING(Teams[Name], "Member2"),
CONTAINSSTRING(Teams[Name], "Member3") ),
"Y", "N" )
- AnonymousNot applicable
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 TeamIf 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!