COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: v2k4u on 22 Oct 2014 03:02:41 PM

Title: How to use multiple values in a Like function
Post by: v2k4u on 22 Oct 2014 03:02:41 PM
Hi Gurus,

I have a question on using the Like function. Can we use the Like function for mutliple values, for Ex: [Region] Like ('%A','%B','%C') or should we be using it as ([Region] Like ('%A') and [Region] Like ('%B') and [Region] Like ('%C') ).

Please help me with your valuable suggestions.

Thanks
Title: Re: How to use multiple values in a Like function
Post by: Lynn on 22 Oct 2014 03:22:35 PM
You will never find any region that is like %A AND %B since it can only end in one letter.

I don't believe that like allows multiple values. Therefore go with your second approach, but use OR rather than AND
Title: Re: How to use multiple values in a Like function
Post by: MFGF on 23 Oct 2014 10:22:41 AM
Hi,

Personally I would opt for:

[Region] ends with 'A' OR [Region] ends with 'B' OR [Region] ends with 'C'

:)

MF.
Title: Re: How to use multiple values in a Like function
Post by: CognosAnalytics on 24 Oct 2014 03:53:03 PM
Hello v2k4u,
Do you absolutely have to use LIKE ?

Same this can be achieved as such....ignore it if you have to use LIKE.

substring([Region],character_length([Region])) in ('A','B','C')

-Cognos810
Title: Re: How to use multiple values in a Like function
Post by: CognosPaul on 25 Oct 2014 04:55:02 AM
You may also be interested in seeing this thread (http://www.cognoise.com/index.php?topic=22355.0).