COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: kc9400 on 04 Feb 2014 07:58:49 AM

Title: Count no. of records advice.
Post by: kc9400 on 04 Feb 2014 07:58:49 AM
Good afternoon,

run into a bit of a problem. Here is what I've tried so far:

CASE WHEN  [SQL data].[Score] >80 THEN count([SQL data].[APPRO])END)


I can't seem to find any solutions to what I'm trying to achieve. What I need to do is return the number of records displayed which have a Score of >80

Title: Re: Count no. of records advice.
Post by: BigChris on 04 Feb 2014 08:31:22 AM
How about something along the lines of:

sum(CASE WHEN [SQL data].[Score]>80 THEN 1 ELSE 0 END)
Title: Re: Count no. of records advice.
Post by: kc9400 on 04 Feb 2014 10:13:52 AM
I gave that a try but then I'm running into:

Column 'SQL_data.APPRO_NO' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.


What kind of information would be useful for you to be able to best advice me as to how to resolve the problem?
Title: Re: Count no. of records advice.
Post by: Ammus1234 on 05 Feb 2014 02:28:38 AM
Try this.
Use the below dataitem.
CASE WHEN [SQL data].[Score]>80 THEN 1 ELSE 0 END

Change the aggregate function of the dataitem to 'Total'
Title: Re: Count no. of records advice.
Post by: kc9400 on 10 Feb 2014 09:46:18 AM
Cheers for your help. I ended up just modifying the SQL and bringing in an extra data item  :)