Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Wahid777
Frequent Visitor

Creating a conditional column with boolean (Yes/No) result for matching partial text matches

Hi

 

I've got a column listed as below and I'm trying to create a new column (with a Yes/No or True/False response) if some matches of certain keywords are found in the original column. Would "CONTAINS" be useful here? or should I create a new column with my Keywords [CEO, Chief Executive, Officer, CFO, Chief Financial Officer, Ambassador] and use Search?

 

Original columnNew conditional column
Mr John is the CEO of xYes
Ms Lynn is the Vice president of YNo
Tom is the ambassador of USA to the UKYes
Jerry is the Company Secretary of X IncNo

 

Keywords
Ambassador
CEO
Chief Executive Officer
Chief Financial Officer
CFO

 

 

1 ACCEPTED SOLUTION
AntrikshSharma
Community Champion
Community Champion

@Wahid777  You can use CONTAINSSTRING:

Column =
CONTAINSSTRING ( Wahid[Original column], "Ambassador" )
    || CONTAINSSTRING ( Wahid[Original column], "CEO" )
    || CONTAINSSTRING ( Wahid[Original column], "Chief Executive Officer" )
    || CONTAINSSTRING ( Wahid[Original column], "Chief Financial Officer" )
    || CONTAINSSTRING ( Wahid[Original column], "CFO" )

 1.PNG

View solution in original post

3 REPLIES 3
v-stephen-msft
Community Support
Community Support

Hi @Wahid777 ,

 

You could refer to Finding if a value in table 1 has a matching value in table 2.
You need a Keywords table by entering and there is no relationship between two tables.

1.png

2.png

Column 3 = 
IF (
    SUMX (
        'Keywords',
        FIND ( UPPER ( 'Keywords'[Keywords] ), UPPER ( [Original column] ),, 0 )
    ) > 0,
    "True",
    "False"
)

Untitled picture.png

 

You can check more details from here.


Best Regards,
Stephen Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

AntrikshSharma
Community Champion
Community Champion

@Wahid777  You can use CONTAINSSTRING:

Column =
CONTAINSSTRING ( Wahid[Original column], "Ambassador" )
    || CONTAINSSTRING ( Wahid[Original column], "CEO" )
    || CONTAINSSTRING ( Wahid[Original column], "Chief Executive Officer" )
    || CONTAINSSTRING ( Wahid[Original column], "Chief Financial Officer" )
    || CONTAINSSTRING ( Wahid[Original column], "CFO" )

 1.PNG

@Wahid777  I think you can go with the solution provided by @AntrikshSharma if you can't make changes to the alrady captured data. However, as a data analyst it is always recomended to have a clean data in the database itself. I suggest if possible please create a seperate column in your data itself for the position. For Example CEO or Chief Executive Officer are the same position. So ideally you would like to have one keyword for similar positions etc.




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors