COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: dwong11229 on 28 Sep 2018 07:54:15 PM

Title: Count a data item occurence within a date range
Post by: dwong11229 on 28 Sep 2018 07:54:15 PM
Hi

How to count data item within a date range

I have NameId data item and a Creation date data item

I want to count the number of NameID that is between 2018 and 2017

So lets say NameID appeared in date range between 2017 and 2018 have three NameID
The end result will be 3.


Thanks
Title: Re: Count a data item occurence within a date range
Post by: Lynn on 05 Oct 2018 08:22:57 AM
Quote from: dwong11229 on 28 Sep 2018 07:54:15 PM
Hi

How to count data item within a date range

I have NameId data item and a Creation date data item

I want to count the number of NameID that is between 2018 and 2017

So lets say NameID appeared in date range between 2017 and 2018 have three NameID
The end result will be 3.


Thanks

Assuming your package is relational, try something like this:


count ( case when [Creation date] between 2017-01-01 and 2018-12-31 then [NameID] else null )