COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: Avisto.sbu on 13 Mar 2014 10:41:14 AM

Title: Detail filter expression
Post by: Avisto.sbu on 13 Mar 2014 10:41:14 AM
Hi,

I have a field named 'terminal' and I don't want this field to be mandatory, the default behaviour should be that all terminals are selected in the report if there is no selection.

So I tried to create a filter :


if(?selection terminal QS?  is missing)
then([(en-zw) Nouvel espace-noms4].[(en-zw) Raccourci de pdv].[(en-zw) shop_terminal] = [(en-zw) Nouvel espace-noms4].[(en-zw) Raccourci de pdv].[(en-zw) shop_terminal])
else([(en-zw) Nouvel espace-noms4].[(en-zw) Raccourci de pdv].[(en-zw) shop_terminal] = ?selection terminal QS?)


Obviously it is not working as I don't know report studio syntax and I don't find any tutorial about the syntax in filters
the parameter becomes mandatory as soon as I put a filter in the main query :(

actually I want to filter a value when something is selected, and when nothing is selected, every values are used for the main query.
I think we can't create a if without a 'else' so that's why I put value=value in the 'Then'

How can I do?

thanks for your answers
Title: Re: Detail filter expression
Post by: BigChris on 13 Mar 2014 11:15:40 AM
Hi - I think you just need to make the filter optional. That if the user selects a value it'll use it in the filter...and not if they don't.
Title: Re: Detail filter expression
Post by: Avisto.sbu on 14 Mar 2014 05:01:37 AM
thanks for your answer,

as the 'else' condition is mandatory in the filter syntax what should I do if I want nothing to be done in that condition without having a sql error?
for example if I modify the previous query I could have:


if(?selection terminal QS?  is not missing)
then( [(en-zw) Nouvel espace-noms4].[(en-zw) Raccourci de Point de vente].[(en-zw) shop_terminal]= ParamDisplayValue('selection terminal QS'))
else(1=1)

[\code]
But it is not working I have a sql error
Title: Re: Detail filter expression
Post by: BigChris on 14 Mar 2014 06:19:11 AM
I think you can just change your filter to be:

[(en-zw) Nouvel espace-noms4].[(en-zw) Raccourci de Point de vente].[(en-zw) shop_terminal]= ?selection terminal QS?

and make the filter optional.

Can I just check - is this a relational model, or a dimensional one?
Title: Re: Detail filter expression
Post by: Avisto.sbu on 14 Mar 2014 09:21:34 AM
thank you very much it works :)

it is a dimensional model
Title: Re: Detail filter expression
Post by: bdbits on 18 Mar 2014 10:53:37 AM
You really should not use filters on dimensional sources. CognosPaul has explained this many times in various places. Here is one.

http://www.cognoise.com/community/index.php?topic=18290.0;topicseen
(http://www.cognoise.com/community/index.php?topic=18290.0;topicseen)