Forum Discussion
Creating New Column Based on a Set of Text Strings
- 6 years ago
Hi, NewBIEnthusiast
Based on your description, you may click ‘Edit Query’, go to Query Editor, enter ‘Query Settings’, right-click last step, select ‘Insert Step After’.
Then you may input ‘Table.AddColumn(#"Changed Type", "Custom", each if [Color_Name] = "red" or [Color_Name] = "blue" or [Color_Name] = "red;blue" or [Color_Name] = "blue;red" then "Exclude" else "Valid")’ in the formula area.
Result:
As a workaround, you can also create a calculated column as follows.
IsExclude =
IF(
EXACT('Table'[Color_Name],"red")||
EXACT('Table'[Color_Name],"blue")||
EXACT('Table'[Color_Name],"red;blue")||
EXACT('Table'[Color_Name],"blue;red"),
"Exclude",
"Valid"
)
Result:
Best Regards,
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Use search
https://docs.microsoft.com/en-us/dax/search-function-dax
if(search("Red",color_name)>0 &&search("Blue",color_name)>0 , "Exclude","Include")
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p/881739
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601