Thursday, September 4, 2008

Checking for Empty Parameters in Cognos 8

Hey, I'm finally writing something about Cognos 8. This would most likely apply to any earlier version of ReportNet as well:

I have a report that needs to display the value of the optional ?market? parameter if it's used. If it's not used, I need it to display "Southeast Region." The first instinct is to do something like

if(ParamDisplayValue('market') = '') then
('Southeast Region') else
(ParamDisplayValue('market'))

This doesn't work, though, because not selecting a parameter value does not result in that parameter equaling an empty string. All you get is a blank area on the report where 'Southeast Region' should be. I also tried using character_length('market'), but that had the same result.

The solution is to use the ParamCount() function. So my final code looked something like this:

if(ParamCount('market') = 0) then

('Southeast Region') else
(ParamDisplayValue('market'))

Problem solved!

1 comment:

Unknown said...

I think ParamValue('Value') is null would work too