COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: SGD on 07 Jun 2011 02:47:35 AM

Title: Resolved: CASE WHEN
Post by: SGD on 07 Jun 2011 02:47:35 AM
Hi,

I am using Cognos RS 8.4.1 and getting following error when using 'CASE WHEN' statement.

QuoteUDA-SQL-0358 Line 54: Syntax error near "and".

Case when statement:
Quotecase
when (?p_axle_than? = 'ge')
then ([Axle Level View].[Axle Fact].[Number of Axles] >= ?p_axle?)
when (?p_axle_than?= 'le')
then ([Axle Level View].[Axle Fact].[Number of Axles] <= ?p_axle?)
when (?p_axle_than?= 'all')
then ([Axle Level View].[Axle Fact].[Number of Axles])
end

I am applying above statement as a filter which validates without any issue; even report validaes without any error message.

Above error message displays when I click 'Finish' button after selecting appropriate prompt values.

Could please anyone guide me to resolve this issue?
Title: Re: CASE WHEN
Post by: PRIT AMRIT on 07 Jun 2011 03:13:56 AM
QuoteI am applying above statement as a filter which validates without any issue; even report validaes without any error message.

Try this?
?p_axle_than? = 'ge' and
[Axle Level View].[Axle Fact].[Number of Axles] >= ?p_axle?
or
?p_axle_than?= 'le' and
[Axle Level View].[Axle Fact].[Number of Axles] <= ?p_axle?
or
?p_axle_than?= 'all' and
[Axle Level View].[Axle Fact].[Number of Axles] is not null




Title: Re: CASE WHEN
Post by: navissar on 07 Jun 2011 04:23:59 AM
try:

case ?p_axle_than?
when 'ge' then [Axle Level View].[Axle Fact].[Number of Axles] >= ?p_axle?
when 'le' then [Axle Level View].[Axle Fact].[Number of Axles] <= ?p_axle?
else [Axle Level View].[Axle Fact].[Number of Axles]
end

Title: Re: CASE WHEN
Post by: hthakkar on 07 Jun 2011 04:31:32 AM
Hi Shirish Dawane,

Are you trying to cascade something out from this case statement??

Thanks,
Hitesh

--------------------------------------------------------
hthakkar@infocepts.com|www.infocepts.com
--------------------------------------------------------
Title: Re: CASE WHEN
Post by: SGD on 08 Jun 2011 02:38:29 AM
Hi,

I have two prompts.

One is dropdown which shows '>=', '<=' & 'All' as display values and 'ge', 'le' & 'all' as use values respectivly.

Other one is text prompt which only allows numbers to be entered.

So here I want to User selects values from 1st prompt and then enter number in 2nd prompt. If User selects 'All' then is should display all the values irrespective of greater than or less than.

e.g. if User enters '>=' & '0' values then it should show values which are greater that '0' however if User selects 'All' then is should show all the values.

Any thoughts?
Title: Re: CASE WHEN
Post by: SGD on 08 Jun 2011 02:44:22 AM
Hi,

It works fine if I modify this statement as below:

Quotecase
when (?p_axle_than? = 'ge')
then ([Axle Level View].[Axle Fact].[Number of Axles] >= ?p_axle?)
when (?p_axle_than?= 'le')
then ([Axle Level View].[Axle Fact].[Number of Axles] <= ?p_axle?)
when (?p_axle_than?= 'all')
then ([Axle Level View].[Axle Fact].[Number of Axles] = 0)
end

But I want to display all the values of [Number of Axles] query item.
Title: Re: CASE WHEN
Post by: blom0344 on 08 Jun 2011 02:56:35 AM

case
when (?p_axle_than? = 'ge')
then ([Axle Level View].[Axle Fact].[Number of Axles] >= ?p_axle?)
when (?p_axle_than?= 'le')
then ([Axle Level View].[Axle Fact].[Number of Axles] <= ?p_axle?)
when (?p_axle_than?= 'all')
then ( 1 = 1 )
end

Title: Re: CASE WHEN
Post by: SGD on 08 Jun 2011 03:23:50 AM
Thanks a lot blom0344...it worked.  :)

Also, thanks to everyone who tried to help!!!