COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: andy_mason_84 on 24 Jul 2012 08:13:05 AM

Title: How to IF ELSE THEN AND IF ... in Report Studio
Post by: andy_mason_84 on 24 Jul 2012 08:13:05 AM
Folks,

I have a really simple question but for some reason i am having a mental block ...

I have a report with say 5 seperate prompts on the prompt page ...

I have put a Report Expression into the main body on the report to basically show the parameters if they are selected in the header so if people print the reports they know what they have filtered on.

This is the code i have used.

IF (ParamDisplayValue('Module_Name') is NULL)
THEN
('')
ELSE
('Module(s): '+ParamDisplayValue('Module_Name'))


Right,

Now I want to basically say

IF (ParamDisplayValue('Module_Name') is NULL)
THEN
('')
ELSE
('Module(s): '+ParamDisplayValue('Module_Name'))

IF (ParamDisplayValue('Company_Name') is NULL)
THEN
('')
ELSE
('Company(s): '+ParamDisplayValue('Company_Name'))


So that if the select no parameters then nothing will appear ...

If they just select a Module then just Module Name will Appear

If they select just a Company then Companies will appear

and if they select both then they will both appear.

I can't have seperate if statements as it doesnt like it but i dont want to have code for every possible scenario ...

Any suggestions?

Cheers,

Andy
Title: Re: How to IF ELSE THEN AND IF ... in Report Studio
Post by: MFGF on 24 Jul 2012 08:39:10 AM
How about putting the two if expressions into separate items and displaying both items? Are these layout calculations or query calculations?

Cheers!

MF.
Title: Re: How to IF ELSE THEN AND IF ... in Report Studio
Post by: andy_mason_84 on 24 Jul 2012 08:44:35 AM
Hey,

They are just Text Items with Source Type as Report Expression.

I could in theory have 5 text items next to each other, just wanted to have it all in one.

Thanks for the idea though ... will give that a whirl.
Title: Re: How to IF ELSE THEN AND IF ... in Report Studio
Post by: cschnu on 24 Jul 2012 09:23:37 AM
As MF said try putting them as separate items and then Report Studio will handle printing them or not.  If they don't select an optional parameter Report Studio will not print the entire expression. You can still put each expression on the same line by using a block or a table.
Title: Re: How to IF ELSE THEN AND IF ... in Report Studio
Post by: andy_mason_84 on 24 Jul 2012 09:48:43 AM
Thanks.