COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: reginoilano on 08 Apr 2010 03:38:12 AM

Title: Conditional Filter in Report Studio
Post by: reginoilano on 08 Apr 2010 03:38:12 AM
Hi,

I have a conditional filter in a report where in they can choose if they would like to see Zero values for a certain measure. but once I run the report specially when they don't want to see Zero amount an error occured stating that it is a wrong expression type

the code is:

If (?Prompt Display Zero Amount? = 'Yes') Then
([Amount])
Else
(([Amount]) > 0)

anyone have tried this?
Title: Re: Conditional Filter in Report Studio
Post by: MFGF on 08 Apr 2010 05:42:57 AM
Hi,

I'm a little confused by the syntax you are using here, so I'm not surprised Cognos 8 is returning an Expression Type error.

Assuming this is a filter not a calculation, it doesn't make sense, as the two returned filter expressions possible are either

[Amount]

or

[Amount] > 0

The latter looks to be OK, but the former is not a filter expression.

The expression wouldn't make sense in a calculation either, as [Amount] > 0 does not return a calculated value.


I would amend the filter to be something like:

If (?Prompt Display Zero Amount? = 'Yes') Then
([Amount] is not null)
Else
([Amount] > 0)

Both of the returned expressions are now valid filters, so hopefully should return desired results.

Regards,

MF.
Title: Re: Conditional Filter in Report Studio
Post by: reginoilano on 08 Apr 2010 06:29:52 AM
Thanks!

I did make a mistake for that conditional filter, now it's working!  :)
Title: Re: Conditional Filter in Report Studio
Post by: cognos4all on 09 Apr 2010 05:47:09 PM
i have a report where i want to do the conditional filter but i am getting error when i try to do similar like this.
I have a report with optional date prompt, When i run the report first time i want to run the report for last 15 days (this is the dafault), but when the user select the data range from the date prompt then i want to apply selected date as filter instead of default date filter. I am using date prompt control in the report.

i tried this and didn't worked. What am i doing wrong.

If (  ?SelectedDateRange? is not missing  ) then
[Date] in_range ?SelectedDateRange?
else
[Date] >=  _add_days (current_date , -15)
Title: Re: Conditional Filter in Report Studio
Post by: MFGF on 13 Apr 2010 04:46:37 AM
What error is returned when you do this?
Title: Re: Conditional Filter in Report Studio
Post by: pratyush on 13 Apr 2010 10:01:43 AM
Quote from: reginoilano on 08 Apr 2010 03:38:12 AM
Hi,

I have a conditional filter in a report where in they can choose if they would like to see Zero values for a certain measure. but once I run the report specially when they don't want to see Zero amount an error occured stating that it is a wrong expression type

the code is:

If (?Prompt Display Zero Amount? = 'Yes') Then
([Amount])
Else
(([Amount]) > 0)

anyone have tried this?


Hi

You must be either using list or crosstab for the same, you need to check the dataitem [Amount] under the properties of either list or crosstab ...

Cheers ..........