COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: cognosguru on 26 May 2021 10:23:25 AM

Title: How to do a contains in a filter looking for ' (in O'Sullivan)
Post by: cognosguru on 26 May 2021 10:23:25 AM
Hi folks,

I need to do a report finding all employees whose name contains a special character.  I can do contains '&' or contains '@' with no issues.  Where I get a syntax error is when I am trying to find all employees with an apostrophe (O'Sullivan, etc.).

Any suggestions?

Thanks!
Title: Re: How to do a contains in a filter looking for ' (in O'Sullivan)
Post by: adam_mc on 26 May 2021 02:20:25 PM
Have you tried adding a second quote?
Something like contains ''''

Not sure, but I think it is something along these lines if I remember correctly.

Hope this helps,
Adam.
Title: Re: How to do a contains in a filter looking for ' (in O'Sullivan)
Post by: dougp on 27 May 2021 11:20:48 AM
[DataItem] contains '(O''Sullivan, etc.)'
Title: Re: How to do a contains in a filter looking for ' (in O'Sullivan) - Solved!
Post by: cognosguru on 01 Jun 2021 05:49:12 PM
So this is fun and here's how I solved it:

I tried to create a simple filter not using Advanced and it worked by seemingly having Name contains '
When I do the same in advanced it fails so I examined the SQL and got this, tested it in advanced and it works:

[Employee Name (Last Suffix, First MI)] like '%''%'

Wow.
Title: Re: How to do a contains in a filter looking for ' (in O'Sullivan)
Post by: dougp on 02 Jun 2021 02:03:16 PM
I think that's what adam_mc was saying:
[DataItem] contains ''''
Title: Re: How to do a contains in a filter looking for ' (in O'Sullivan)
Post by: cognosguru on 02 Jun 2021 02:52:15 PM
Doug and Adam yes '''' works also.  I am still trying to understand mechanics of it instead of ''' because it seems to find anything and then something else and the ' is just whatever is in the middle?