cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
kleetus51 Member
Member

Add column based on a list from another table

I have two tables. Table 1 contains a list of keywords with the associated category. Table 2 contains a summary and description of work to be done. I want to calculate a column in Table 2 that will seach for values from the summary and description columns in Table 2 and then search the keywords column in Table 1 to see if any of the keywords are contained in the text. If found assign it the corresponding category for the keyword. If not, mark it Other.

 

Here is a simplified version of my data:

 

Table 1:

KeywordCategory
WIRINGNetwork
ROUTERNetwork
PCWorkstation
VMServer

 

Table 2: I'd like the results to populate in the Category column

SummaryDescriptionCategory
NETWORK CABLINGTHIS WORK IS TO REROUTE NETWORK WIRINGNetwork
ROUTER CONFIGTHIS IS TO CONFIGURE ROUTER 2Network
WORKSTATION REIMAGEREIMAGE BOB'S PCWorkstation
VM CONFIGURECONFIGURE VIRTUAL MACHINEServer
BATTERY REPLACEMENTREPLACE THE BATTERIES IN BOB'S MOUSEOther
1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Add column based on a list from another table

Hi @kleetus51

 

Try this for your calculated column:

 

Category = 
VAR _ResultCategory =
    CONCATENATEX (
        VALUES ( Table1[Keyword] );
        IF (
            (
                FIND ( Table1[Keyword]; Table2[Summary]; 1; 0 ) > 0
                    || FIND ( Table1[Keyword]; Table2[Description]; 1; 0 ) > 0
            );
            LOOKUPVALUE ( Table1[Category]; Table1[Keyword]; Table1[Keyword] )
        )
    )
RETURN
IF(LEN(_ResultCategory)=0;"Other";_ResultCategory)

 

Code formatted with   www.daxformatter.com

View solution in original post

2 REPLIES 2
Super User
Super User

Re: Add column based on a list from another table

Hi @kleetus51

 

Try this for your calculated column:

 

Category = 
VAR _ResultCategory =
    CONCATENATEX (
        VALUES ( Table1[Keyword] );
        IF (
            (
                FIND ( Table1[Keyword]; Table2[Summary]; 1; 0 ) > 0
                    || FIND ( Table1[Keyword]; Table2[Description]; 1; 0 ) > 0
            );
            LOOKUPVALUE ( Table1[Category]; Table1[Keyword]; Table1[Keyword] )
        )
    )
RETURN
IF(LEN(_ResultCategory)=0;"Other";_ResultCategory)

 

Code formatted with   www.daxformatter.com

View solution in original post

kleetus51 Member
Member

Re: Add column based on a list from another table

Works perfectly. Thanks!

Helpful resources

Announcements
Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 319 members 3,531 guests
Please welcome our newest community members: