Forum Discussion

PamelaAG's avatar
PamelaAG
Frequent Visitor
3 years ago
Solved

Search within a text column if one or multiple KeyWords are a match

Hi all,

I would like to know if there is a way to create a new column that looks for different keyworkds and create a list of all possible results. 

For example, based on the following table 

 

ItemItem Description
aDetail 1, Detail 2, Detail 3
bDetail 2, Detail 4,
cDetail 2, Detail 6

 

I would like to create a calculated colum that contains all possible Details, so if I filter "Detail 1", the table is going to show all Items that contains "Detail 1", if I filter "Detail 2", all that contains "Detail 2", and so on. 

 

I already tried with the following function 

 

 

SWITCH(TRUE(),
                    IF(SEARCH("Detail 1", 'Table'[Item Description], , 0) > 0  
                    ,TRUE()
                        ,FALSE())
                        ,"Detail 1",
                    
                     IF(SEARCH("Detail 2",  'Table'[Item Description], , 0) > 0  
                    ,TRUE()
                        ,FALSE())
                        ,"Detail 2",

                    "MISSING STATUS"
                        )               

 

But it doesn't bring all possible matches, only the first one. 
 
Is there another way to solve this. 
 
Thank you so much in advance. 
 
  • Here is one approach to consider. I made a disconnected table with your Detail values and used the measure below in a table visual. The row that does not include one of the selected values is automatically filtered out.

     

    ContainsSlicerValue =
    VAR slicerlist =
        VALUES ( SlicerValues[Detail] )
    VAR thisitemdesc =
        MAX ( T3[Item Description] )
    VAR filtered =
        FILTER ( slicerlist, CONTAINSSTRING ( thisitemdesc, SlicerValues[Detail] ) )
    RETURN
        IF ( COUNTROWS ( filtered ) > 0, "Y" )

     

    Pat

     

     

4 Replies

  • ppm1's avatar
    ppm1
    Solution Sage

    Here is one approach to consider. I made a disconnected table with your Detail values and used the measure below in a table visual. The row that does not include one of the selected values is automatically filtered out.

     

    ContainsSlicerValue =
    VAR slicerlist =
        VALUES ( SlicerValues[Detail] )
    VAR thisitemdesc =
        MAX ( T3[Item Description] )
    VAR filtered =
        FILTER ( slicerlist, CONTAINSSTRING ( thisitemdesc, SlicerValues[Detail] ) )
    RETURN
        IF ( COUNTROWS ( filtered ) > 0, "Y" )

     

    Pat

     

     

    • PamelaAG's avatar
      PamelaAG
      Frequent Visitor

      Hi Pat! 

       

      Thank you so much for your help, it seems you are getting exactly what I need.

      I tried to follow your instructions, but, the moment I select something on filter, nothing happens on the table.

      Did you somehow connected both tables? 

    • PamelaAG's avatar
      PamelaAG
      Frequent Visitor

      I just figured it out where my mistake was! thank you so much for your help! it helped me a lot!

       

      Thank you!