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
Turnipface
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

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

4 REPLIES 4
Kristjan76
Responsive Resident
Responsive Resident

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

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

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
   )
)

Is there a version of this that would work if one table is direct query? The COUNTROWS function isn't supported in direct query.

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.