Like condition in Crystal Reports

 4 Replies
 0 Subscribed to this topic
 22 Subscribed to this forum
Sort:
Author
Messages
Nabil
Veteran Member
Posts: 61
Veteran Member
    Hi everyone,

    I'm trying to filter a job description to include only people with certain stings. For example:
    If Employee A job title includes "Manager" then include it
    Usually Job title fields would contain a long description like "AS0 HR Manager 2 Loc" I'm only interested in the "Manager" part.

    I tried using like "" but that didn't work.

    Regards,
    Kelly H
    Veteran Member
    Posts: 167
    Veteran Member
      try putting =*Manager* in your formula. I sometimes have to do it that way instead.
      FireGeek21
      Veteran Member
      Posts: 84
      Veteran Member
        Basic and Crystal syntax.

        The Like operator is useful for selecting records to include or exclude from your report.

        Usage
        x like y

        {fieldname} like "c?n*"

        This operator tests to see if the contents of {fieldname} matches a pattern that you specify in a character string "c?n*". If the contents of the field do fit the pattern "c?n*", then the formula returns the value True. If the field starts with anything else, the formula returns False.

        Use the wildcard symbols ? and * to stand for variable characters. The ? stands for a single character. The * symbol stands for any number of characters.

        Examples
        The following examples are applicable to both Basic and Crystal syntax:

        {customer.FIRST NAME} like "D?n"

        TRUE, where {customer.FIRST NAME} = Dan or Don.

        {customer.FIRST NAME} like "D?n"

        FALSE, where {customer.FIRST NAME} = Doug or Rob.

        {customer.LAST NAME} like "*s?n*"

        TRUE, where {customer.LAST NAME} = Johnson or Olson or Olsen.

        {customer.LAST NAME} like "*s?n*"

        FALSE, where {customer.LAST NAME} = Johnston or Smith.

        Char
        Veteran Member
        Posts: 62
        Veteran Member
          Instr({table.field}, 'Manager') >0 - the first arguement is your database field and the second argument is the search string - it returns an integer that represents the numeric location of the first letter of the word Manager within the searched string - if it didn't return stomething greater than 0 then Manager wasn't found. The only drawback to this is that it won't pass in your where clause. If this were my report, I'd use a SQL Expression with the appropriate function based on your database to get it to pass in the where clause. If you don't know how to do that - tell me what your database type is and if I have time, I'll send you the SQL expression code.
          FireGeek21
          Veteran Member
          Posts: 84
          Veteran Member
            Try:

            {TABLENAME.FIELDNAME} LIKE "*Manager*"

            TViola