COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: vanlang on 27 Sep 2013 02:51:13 PM

Title: Passing a Parameter into a Data Item
Post by: vanlang on 27 Sep 2013 02:51:13 PM
Good afternoon Cognoise world!

In my report, there is a value prompt which sets a parameter. The parameter IS NOT required (i.e. it is optional)

I then have a data item, that I created, and I use the contents of the parameter to help determine the data item, via the case statement below:

CASE ?parameter? IS NULL

WHEN NOT [field] OR NULL
      THEN 'text 1'

END

The statement works, so the coding is not the issue, the issue being that it turns the aforementioned parameter Required, which is not what I want.

If anyone knows how to fix this, or needs clarification, please let me know!

Thanks,

-- V
Title: Re: Passing a Parameter into a Data Item
Post by: blom0344 on 27 Sep 2013 03:36:29 PM
Reference within a dataitem does indeed make the parameter mandatory.  If you think this through , it is only logical. Your case can only be evaluated IF a value exist to be compared.
Title: Re: Passing a Parameter into a Data Item
Post by: CognosPaul on 29 Sep 2013 04:06:15 PM
But you can make it optional by providing a default value.

For example:

case #prompt('parameter','string',sq('default'))#
when 'default' then 'default action'
when 'and' then 'and action'
when 'so' then 'so action'
else 'on'
end
Title: Re: Passing a Parameter into a Data Item
Post by: vanlang on 30 Sep 2013 07:19:09 AM
Thank you very much for your help!

It did make sense that it needed to be mandatory after I thought about it a little!

But both solutions worked! Thanks again!
Title: Re: Passing a Parameter into a Data Item
Post by: maxchuie on 07 Feb 2014 01:21:45 PM
Hi CognosPaul
I did this and i get 'All' as the rank for everything

case #prompt('?pRankGroup?','string',sq('?pRankGroup?'))#
When 'Top 5' then '5'
When 'Top 10' then '10'
When 'Top 15' then '15'
When 'Top 20' then '20'
When 'Top 25' then '25'
Else 'All'
end
Title: Re: Passing a Parameter into a Data Item
Post by: CognosPaul on 09 Feb 2014 11:50:21 PM
When using a prompt macro you don't need the question marks. Get rid of those and try again.