COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: wwconslt on 04 Mar 2020 10:33:33 AM

Title: Wild Card for Nine Digit Zip Codes in Prompt
Post by: wwconslt on 04 Mar 2020 10:33:33 AM
Hello Everyone,

Relational Data Model.

I'm trying to create an optional prompt where the user can enter zip codes they would like to EXCLUDE from the results. Since they will be entering multiple five digit zips, I would like to use a wild card that says to exclude that five digit zip or any nine digit zip beginning with that five digit zip the user provides.

For example if the user enters 90210, I would like it to exclude the results 90210, 90210-0222, etc.

I've tried different versions of these but none seem to work:
[ZIP_CODE] not in '?Excluded_Zip?+%'
[ZIP_CODE] not in Starts With ?Excluded_Zip?

Thank you!
Title: Re: Wild Card for Nine Digit Zip Codes in Prompt
Post by: dougp on 04 Mar 2020 12:43:54 PM
Try these:
[ZIP_CODE] not in ?Excluded_Zip?+'%'
[ZIP_CODE] not Starts With ?Excluded_Zip?
Title: Re: Wild Card for Nine Digit Zip Codes in Prompt
Post by: wwconslt on 09 Mar 2020 09:07:28 AM
Thanks Doug.  Unfortunately, the first example throws a parsing error.  The second example works but only with one zip entered at a time.  The users need the ability to paste in up to 1000 zip codes in an optional, multi-line, multi-select text box prompt.  Usually requires the word "in"  [ZIP_CODE] in ?Excluded_Zip?
Title: Re: Wild Card for Nine Digit Zip Codes in Prompt
Post by: ashley on 09 Mar 2020 10:56:25 AM
I think dougp's first example should be [ZIP_CODE] not like ?Excluded_Zip?+'%'. Like allows for wildcard operators, but these are single select only afaik.
Title: Re: Wild Card for Nine Digit Zip Codes in Prompt
Post by: dougp on 09 Mar 2020 11:08:53 AM
Ashley:  Correct.

wwconslt:  left([ZIP_CODE], 5) in ?Excluded_Zip?
This limits the user to entering 5-digit zip codes.
If LEFT doesn't work (you didn't say which RDBMS you are using), you'll need to use SUBSTR.
Title: Re: Wild Card for Nine Digit Zip Codes in Prompt
Post by: wwconslt on 09 Mar 2020 02:18:10 PM
Thank you everyone.  Doug your solution works perfectly--thank you!