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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
rodrigo_avf
Frequent Visitor

Check if text contains key words from another table and return column from other table

Hello,
I have done this using M, but I need it with DAX.


Here is an example of what I have and want to do

rodrigo_avf_0-1689185937002.png

I need to identify if Comment contains any of the keywords, in case it does, it should pull the group.


In a longer version:
I need a DAX column or measure to be added to a table visual where the first column is the entire Comment column, and the second is the column I need to calculate. The measure/column should return the value in Gruop in case the word in Keyword is found in the text contained in the Comment.

2 ACCEPTED SOLUTIONS
Ahmedx
Super User
Super User

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

https://1drv.ms/u/s!AiUZ0Ws7G26RiUw8jVEYBndpdIKg?e=rJrlXc

Screen Capture #1417.png

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

Write these calculated column formulas

keyword = FIRSTNONBLANK(FILTER(VALUES('Comment Group'[keyword]),SEARCH('Comment Group'[Keyword],Comments[Comment],1,0)),1)
Group = LOOKUPVALUE('Comment Group'[Group],'Comment Group'[Keyword],Comments[keyword])

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Write these calculated column formulas

keyword = FIRSTNONBLANK(FILTER(VALUES('Comment Group'[keyword]),SEARCH('Comment Group'[Keyword],Comments[Comment],1,0)),1)
Group = LOOKUPVALUE('Comment Group'[Group],'Comment Group'[Keyword],Comments[keyword])

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you @Ashish_Mathur 
This worked as expected and its pretty easy to understand the DAX code, it was just a bit slow to calculate the keyword column, but it did what I wanted.

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ahmedx
Super User
Super User

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

https://1drv.ms/u/s!AiUZ0Ws7G26RiUw8jVEYBndpdIKg?e=rJrlXc

Screen Capture #1417.png

Thank you @Ahmedx 
Your solution worked as expected, in contrast with what @Ashish_Mathur proposed, your code seems much faster, but a bit harder to read and understand.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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