Power BI: match values between 2 tables based on text filter then show results of the table to the other

I have 2 tables with different values and what I want, it is to search some specific same values in both then for each matching result, I want to show the value of the table 1 to the table 2. Does it make sense what I am saying !!! May be not so let’s take an example. I have those 2 tables:

Table 1 Table 2
power bi power bi

So based on the word in the “comment” and “description” columns, if they match, I want in the table 1 to show the related “number” of table 2. For instance, looking for “nt” and I get this result:

power bi power bi

First, I have to extract the “comment” and “description” into 1 single column in a new table:

power bi

NOTE: to know how, read Power BI: extract columns from a table to another one

Next, I will create a measure with this formula in the new table:


var result=IF(COUNT('table1'[argument])>0,CALCULATE(CONCATENATEX('table2','table2'[argument]," "),ALL('table1')))
return
IF(NOT(ISFILTERED('table3'[argument])),IF(COUNT('table1'[argument])=1,""),IF(ISBLANK(result),IF(COUNT('table1'[argument])=1,""),result))
              
power bi

NOTE:

  • Replace table and argument by yours
  • For more options to combine values based on slicer, read Power BI: filter/slicer

Then I will create a relationship:

power bi

NOTE: make sure that "both" is selected in "cross-filter direction"

power bi

For my example, I will create a text slicer but you can use any kind of slicers:

power bi

NOTE:

  • For other slicers, you may have to update the measure formula -> CALCULATE(updated formula,ALL('table1'))
  • To have this option, go to “file -> options and settings -> options -> preview features -> text slicer visual”
power bi

And a simple table:

power bi

Now, I have all sets:

power bi

If I put in the filter “database”, I will get this result:

power bi

It also works for a partial word, remember in the table 2 for “INC006”, the comment is “data nt”, to show all words containing “data”, I will put in the filter “data”:

power bi

To use multiple keywords, enable this option in the slicer settings:

power bi

By enabling it, the search condition is OR and not AND. For instance:

power bi

It is looking for “data OR win” so giving me more results but sometimes, I want the filter to do “data AND win”. In this case, I will add another one in the “filters” panel either in “filters on this page” or “filters on all pages”:

power bi

NOTE: do not use the same one, it will not work

For more conditions, go to the “basic filtering” to select multiple options then go back to “advanced filtering”:

power bi power bi

Interesting Topics