COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: twister on 13 Jan 2014 11:00:00 AM

Title: Cognos set expression based on condition
Post by: twister on 13 Jan 2014 11:00:00 AM
Hi All,
I have a requirement to use set expression based on condition. Is this possible?

For example, if (caption([selected_value])='A') then (set(C,D))
else (set(E,F))

It is throwing error. ANy guidance?
Title: Re: Cognos set expression based on condition
Post by: MFGF on 13 Jan 2014 11:40:18 AM
Quote from: twister on 13 Jan 2014 11:00:00 AM
It is throwing error. ANy guidance?

...and the error is?????? :)

If I had to guess I'd wager that it is saying your condition needs to return a single item? You could perhaps try adding query items for each of the two sets, and referring to these in your expression? I'm guessing, though. Until you tell us what the error is that's all anyone will be able to do...

MF.
Title: Re: Cognos set expression based on condition
Post by: twister on 13 Jan 2014 11:52:51 AM
Sorry mate. The error is,

XQE-PLN-0093

The query is not supported. The argument at position 2 of 'if' from the data item 'Region or Country' cannot be coerced into a 'Value' expression.

Thanks.
Title: Re: Cognos set expression based on condition
Post by: twister on 13 Jan 2014 11:56:52 AM
This is DQM and I have put the set expressions as data items and referring the data items in the condition.
Title: Re: Cognos set expression based on condition
Post by: MFGF on 13 Jan 2014 11:57:08 AM
Oh ok - a coercion error. What is [selected_value] defined as? According to your expression it should be a level or a member or a set. What is it actually?

Cheers!

MF.
Title: Re: Cognos set expression based on condition
Post by: twister on 13 Jan 2014 12:02:51 PM
if (caption([BI_Reporting].[BI_Store].[BI_Store] -> ?pStore?)='aaaa')
then ([DATAITEM_SET1])
ELSE ([DATAITEM_SET2])
Title: Re: Cognos set expression based on condition
Post by: twister on 23 Apr 2014 07:30:00 AM
Long time but ended with the same problem...This is disallowed in DQM. I get a coercion error when I use the following in DQM.
if (caption([BI_Reporting].[BI_Store].[BI_Store] -> ?pStore?)='aaaa')
then ([DATAITEM_SET1])
ELSE ([DATAITEM_SET2])

This is working fine with CQM. For DQM, I am planning to have 2 dataitems (one for assigning text and the second one to pickup the value of the first text using macro).  However, struggling with the second data item with the macro.

The first dataitem will look something like this,
if (caption([BI_Reporting].[BI_Store].[BI_Store] -> ?pStore?)='aaaa')
then ('DATAITEM_SET1')
ELSE ('DATAITEM_SET2')

the second dataitem would be like #sb('DATAITEM1')#...Any help would be much appreciated?
Title: Re: Cognos set expression based on condition
Post by: twister on 23 Apr 2014 08:10:12 AM
Any idea COgnos Paul? Basically I want to pass dataitem inside a macro. Is this possible?

#sb('DATAITEM1')#