cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate I
Advocate I

Search text for keywords from another, separate table (Search through tags)

Hey PowerBI community,

I found a few similar topics on this subject, but couldn't get it to work for my case specifically. 


In table A i have a Text Column that contains multiple values in random order and of different length.

Text Column
Banana; Juice; Fruit; Plastic Bag
Fruit; Banana; Turnip
Veggies; Beet

 

In Table B, i have the same values split into rows in a single column called Keywords, with duplicates removed.

Keyword
Banana
Juice
Fruit
Turnip
Veggies
Beet
Plastic Bag

 

Both tables have no relationship between each other.

How can i use Table B to filter Table A and all its associated values based on a Keyword. 
For example, i want to select "Banana" from a filter menu and have the dashboard filtered by all items from Table A that contain "Banana" in their text column.

How could i go about doing this? Based on what i saw, my guess is that i'd need to go with something like RELATEDTABLE, FILTER, SEARCH, etc. 

Many thanks in advance for any feedback on that!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Resolver V
Resolver V

Re: Search text for keywords from another, separate table (Search through tags)

Hi again,

 

The problem is that second filter is returning many rows instead of just TRUE / FALSE, hence in order to get either true or false you can do  (there might be a better solution out there)

NrRows = 
COUNTROWS(
  FILTER(
    TableA;
    COUNTROWS(
      FILTER(
        SUMMARIZE(
          VALUES(TableB[Keyword]);
          TableB[Keyword];
          "result"; PATHCONTAINS(TableA[Text Column]; TableB[Keyword])
        );
        [result]
      ) > 0
   )
)

View solution in original post

3 REPLIES 3
Highlighted
Resolver V
Resolver V

Re: Search text for keywords from another, separate table (Search through tags)

I have solved this by using the Path functions.

 

1. I replace the "; " with "|" in the Text Column, you can either do that in the Query editor or add new calculated column.
2. Then I add a measure, e.g. count the rows that contain this value:

NrRows = 
COUNTROWS(
  FILTER(
    TableA;
    FILTER(
      VALUES(TableB[Keyword]);
      PATHCONTAINS(TableA[Text Column], TableB[Keyword])
  )
)

Hope that this works, and helps with what you are trying to achive.

 

Regards,

Kristjan76

Highlighted
Advocate I
Advocate I

Re: Search text for keywords from another, separate table (Search through tags)

Hi Kristjan,

thanks for your reply!
Although the adapted measure does not result in an error when saved, it does result in an error when trying to display the visual:
"Calculation error in measure 'measure name': A table of multiple values was supplied where a single value was expected"
Do you know which field this could be refering to? 

Thanks,
Stefan

Highlighted
Resolver V
Resolver V

Re: Search text for keywords from another, separate table (Search through tags)

Hi again,

 

The problem is that second filter is returning many rows instead of just TRUE / FALSE, hence in order to get either true or false you can do  (there might be a better solution out there)

NrRows = 
COUNTROWS(
  FILTER(
    TableA;
    COUNTROWS(
      FILTER(
        SUMMARIZE(
          VALUES(TableB[Keyword]);
          TableB[Keyword];
          "result"; PATHCONTAINS(TableA[Text Column]; TableB[Keyword])
        );
        [result]
      ) > 0
   )
)

View solution in original post

Helpful resources

Announcements
June 2020 Community Highlights

June 2020 Community Highlights

Featured community members, changes to the Community, and more! Read up on recent Power BI community news.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors