COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: cognos05 on 05 May 2014 08:04:07 AM

Title: Count IF -on a condition
Post by: cognos05 on 05 May 2014 08:04:07 AM
Hi,

I wanted to count the number of accounts nested under a sales rep for those whose measure value is negative value for one of the columns.
                            YTD      PYTD    Account count for YTD with negative value
Sales rep Acct1    1            45          1
                Acct2    34          -36         1
                Acct3    -456     -456         1

So in the above example, I should get the count as 1 if the column is YTD with respect to sales rep
Below expression was used to count the number of accounts under each rep
count([Measure] within set siblings(currentMember([Your Rep and Account hierarchy])))

But now I should use a condition on my count, like if the value in the column YTD is negative then count the accounts under the rep.

I dont see a countif function i cognos,is there a way to achieve this.
Thanks,
Nithya
Title: Count IF -on a condition
Post by: MFGF on 05 May 2014 03:37:18 PM
I would use a filter() function around the set of siblings you are counting - the filter will return only those members whose measure value is negative. Would this work for you?

MF.


Sent from my iPad using Tapatalk HD
Title: Re: Count IF -on a condition
Post by: cognos05 on 05 May 2014 07:05:56 PM
Yes, it worked perfectly. Why dint I think of it :(.

Thanks MFGF you are awesome!!
Title: Re: Count IF -on a condition
Post by: cognos05 on 06 May 2014 08:34:50 AM
Hi MFGF,

I am trying to use the same functions in cognos 8.1 and cognos 10.2.1 .

It is working perfectly in Cognos 10 , but in 8 I add a query calculation or a data item  and add this item in the column and used filter() function around the set of siblings that I am counting, I dont get any error, but my Query item doesnt show up in the column.I am not sure why is it so, it is the same code as in cognos 10.

Thanks,
Nithya
Title: Re: Count IF -on a condition
Post by: MFGF on 06 May 2014 11:23:04 AM
Quote from: nithya1224 on 06 May 2014 08:34:50 AM
Hi MFGF,

I am trying to use the same functions in cognos 8.1 and cognos 10.2.1 .

It is working perfectly in Cognos 10 , but in 8 I add a query calculation or a data item  and add this item in the column and used filter() function around the set of siblings that I am counting, I dont get any error, but my Query item doesnt show up in the column.I am not sure why is it so, it is the same code as in cognos 10.

Thanks,
Nithya

What precise version of 8?

MF.
Title: Re: Count IF -on a condition
Post by: cognos05 on 06 May 2014 12:07:20 PM
Version 8.1
Title: Re: Count IF -on a condition
Post by: MFGF on 06 May 2014 01:39:05 PM
Quote from: nithya1224 on 06 May 2014 12:07:20 PM
Version 8.1

I think your problem is right there. 8.1 (and even 8.2) had some, um, let's call it quirky behaviour using dimensional expressions. When 8.3 was released and things got tightened up, lots of reports stopped working. The truth was they never should have worked but 8.1 was looser in it's interpretation of MDX than it perhaps could have been.

MF.