COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: maxchuie on 25 Apr 2017 08:22:13 AM

Title: Filter with option to include or exclude data
Post by: maxchuie on 25 Apr 2017 08:22:13 AM
RS 10.2.2 FP8
I need to create a radio button option for Include or exclude and the ability to filter a search and select prompt with it.  Has anyone tried this or can you point me in the right direction.

I did try this http://www.cognosonsteroids.com/2012/03/show-or-hide-date-prompts-based-on.html
but it did not work.

Title: Re: Filter with option to include or exclude data
Post by: New_Guy on 27 Apr 2017 08:22:43 AM
Hi,
Can you explain it with a sample?

Good luck
New guy
Title: Re: Filter with option to include or exclude data
Post by: BigChris on 27 Apr 2017 08:47:09 AM
I haven't tried it, but I would imagine you could write a filter that looks something like:

(?pFilterIncExc? = 'Include' and [YourDataField] contains ?pSearchString?)
or
(?pFilterIncExc? = 'Exclude' and [YourDataField] not contains ?pSearchString?)
Title: Re: Filter with option to include or exclude data
Post by: CognosPaul on 27 Apr 2017 09:27:58 AM
The radio prompt should have:


Use     |     Display
--------+-------------
in      |   Include
not in  |   Exclude


Then your filter would be something like:
[Field] #prompt('includeOrExclude','token')# (#promptmany('searchParam','integer')#)

You could also use a checkbox by doing the following:


Use     |     Display
--------+-------------
not in  |   Exclude


[Field] #prompt('includeOrExclude','token','in')# (#promptmany('searchParam','integer')#)

When the box is checked for exclude, the filter will be "[Field] not in (123,124)" when it is not checked, it will use the default from the macro and be "[Field] in (123,124)"