COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: kishor2010 on 23 Jan 2015 04:51:41 AM

Title: value of the prompt if not entered anything
Post by: kishor2010 on 23 Jan 2015 04:51:41 AM
HI, I have a problem in report studio. please help me to figure this out..
i have a optional prompt, i want to check whether the value is selected or not.. Please help how to check..
if (?parameter? is null ) then ('1') else ('2')
or
if (ParamDisplayValue('parameter') is null ) then ('1') else ('2')
Both the above are not working..
Suppose if i select any value in the prompt then the else part works and i get the result as 2, if i wont select anything then i'm not getting the result as 1
Title: Re: value of the prompt if not entered anything
Post by: BigChris on 26 Jan 2015 02:22:01 AM
Have you tried switching "is null" for "is missing" ? You need to let us know what platform you're using etc.
Title: Re: value of the prompt if not entered anything
Post by: Robl on 26 Jan 2015 04:34:52 AM
You could also try a zero length string.
(?parameter? = '' )

Alternatively use a macro prompt where you can define the blank value.
#prompt('P_paramname','string','unselected')# = 'unselected'

You could set 'unselected' to be whatever you want.

I've also found that for optional prompts the prompt macros tend to run a little faster than having default values in screen based prompts; but I've not actually done any true speed tests.
Title: Re: value of the prompt if not entered anything
Post by: kishor2010 on 28 Jan 2015 04:16:36 AM
Hi Chris,
"is missing" also not working..
I am working in cognos 10.2.2 report studio and the data base is db2..
Title: Re: value of the prompt if not entered anything
Post by: kishor2010 on 28 Jan 2015 04:19:05 AM
Hi Robl
(?parameter? = '' ) and  #prompt('P_paramname','string','unselected')# = 'unselected' are also not wrking...  :( :( :( :(
Title: Re: value of the prompt if not entered anything
Post by: Robl on 28 Jan 2015 05:12:45 AM
Are you sure the prompt has nothing selected?
Have you entered a default value in the prompt on the prompt page?

Try adding a layout calculation on the report that shows the paramvalue and paramdisplayvalue.
You could also try conatenating a string on the front and back of it to see if it's returning spaces, null or zero length string or something else.

Title: Re: value of the prompt if not entered anything
Post by: keshavchhn on 29 Jan 2015 12:34:01 AM
Use "is not null" instead of "is null" in the expression.

You can also check on

http://cogxprt.blogspot.com
Title: Re: value of the prompt if not entered anything
Post by: kishor2010 on 01 Feb 2015 11:20:16 PM
Hi Robl,
I tried as u said,
'a'+ParamDisplayValue('p_AggBand11')+'s'
If i select the prompt value then it will display as below
aCATHAY, CHEUNGKONG,s
if nothing is selected in the prompt then it will not display anything, not even 'a' and 's'
Title: Re: value of the prompt if not entered anything
Post by: Robl on 02 Feb 2015 03:35:40 AM
In which case it's NULL.

Try this
Make sure there is no filter on the report that does anything with the parameter.
Then make a data item with the following calculation; see what happens.
if (?param? is null ) then ('A') else ('B')
Title: Re: value of the prompt if not entered anything
Post by: kishor2010 on 02 Feb 2015 04:20:50 AM
Hi Robl,

If i use the parameter(?param?) in the data item, then that parameter becomes required..
so i can't continue to report without entering the parameter value..
Title: Re: value of the prompt if not entered anything
Post by: Robl on 02 Feb 2015 05:43:05 AM
Good point.
I guess we're back to looking at using a prompt/parameter macro.

Although, looking back at the orginal question..
Add a layout calculation with;

if (ParamValue('param') is null ) then ('a') else ('b')
Title: Re: value of the prompt if not entered anything
Post by: kishor2010 on 04 Feb 2015 03:13:00 AM
Robl,
All these works perfectly in "report expression" but it does not work in "filter expression"..