1 Reply Latest reply on Feb 10, 2016 10:51 AM by David Mannering

    Search Multiple Strings Parameter

    Farris Husseini

      Hi all,

       

      I'm working with survey data that has an open-ended response field. I want to see the amount of surveys that contain specific keywords.

       

      I've created a parameter that can search the open-ended response for 1 single keyword/string. Is it possible to create a single parameter where I can search for multiple keywords?

       

      Thanks

        • 1. Re: Search Multiple Strings Parameter
          David Mannering

          Depending on how you want it to work, you should be able to do this.  In general the strategy would be to let the searcher enter the words as a single string into your parameter.  The words could be separated by a space, comma, or something else.   Then you use the Find() and Mid() functions to split the string into the separate words (by looking for the separator) and then create your filter using contains(word1) AND contains(word2) etc.  Maybe you want to use OR instead of AND here.

           

          So, for example, if I want to search for either of two words I might enter into the parameter (which we'll call [Parm]) "hello friend". 

          Calculation [Space 1] = find([Parm],' ')

          Calculation [Word1] = if [Space1] = 0 then [Parm] else left([Parm],[Space1] - 1) end

          Calculation [Word2] = if [Space1] = 0 then null else mid([Parm],[Space1] + 1)

          Calculation [Search Filter] = contains([Text],[Word1]) OR contains([Text],[Word2])

          This calculation will be true if either word is in the text.  Change it to AND to return true only if both words are in the text.  Also to make it case insensitive wrap each item in an Upper() function. [Search Filter] = contains(upper([Text]),upper([Word1])) OR contains(upper([Text]),upper([Word2]))

           

          You can do this same idea for more than two words, but it gets a little more complicated.  You would start out by finding the second space: [Space2] = find([Parm],' ',[Space1]+1) and so on.

           

          Is this the sort of thing you were looking for?