COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: fml55555 on 24 Jun 2014 10:23:21 AM

Title: Filtering one value based on another
Post by: fml55555 on 24 Jun 2014 10:23:21 AM
Hi Gurus,

I am trying to give a range of values to one data item based on value of another data item.

code
e.g.

case

when (abc = '123')) Then (cc in ('a','b','c','d'))

END

if I tried using if...but I keep getting parsing error.

QE-DEF-0459 CCLException
QE-DEF-0260 Parsing error before or near position: 42 of: "case


what am I doing wrong?
Title: Re: Filtering one value based on another
Post by: Karti on 24 Jun 2014 12:16:47 PM
My usual debugging technique is to throw random letters inside of each part of my filter/query to pinpoint exactly where the error is occurring, due to counting the number of characters can be tedious.

I'm thinking it is missing the ELSE statement. Also not sure if you can use 'in' within the Then statement, but someone can prove me wrong on that.
Title: Re: Filtering one value based on another
Post by: Lynn on 24 Jun 2014 12:36:58 PM
Are you trying to create a filter expression? Is this a relational package?

If yes to both, then you should avoid a case statement and stick with something that evaluates to true or false.


(
  [abc] = '123'
  and
  [cc] in ('a','b','c','d')
)


If you have more conditions, you can expand with "or" between the blocks


(
  [abc] = '123'
  and
  [cc] in ('a','b','c','d')
)
or
(
  [abc] = '456'
  and
  [cc] in ('w','x','y','z')
)


Title: Re: Filtering one value based on another
Post by: fml55555 on 24 Jun 2014 01:25:34 PM
Hi Lynn,

Thanks a lot for the detailed reply. Yes to both. Will try out the method.

Regards,
Venkat