COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: bonfire09 on 18 Oct 2017 11:37:14 PM

Title: How Do I create a running total of unique values?
Post by: bonfire09 on 18 Oct 2017 11:37:14 PM
I want something like this as shown below where I count the # of unique category values. I was  trying
count(distinct [category]) but it was not working.  Any help would be great thanks!
category count
a             1
a             0
b             1
b             0
a             0
c             1
c             0
c             0
Title: Re: How Do I create a running total of unique values?
Post by: MFGF on 19 Oct 2017 03:16:40 AM
Quote from: bonfire09 on 18 Oct 2017 11:37:14 PM
I want something like this as shown below where I count the # of unique category values. I was  trying
count(distinct [category]) but it was not working.  Any help would be great thanks!
category count
a             1
a             0
b             1
b             0
a             0
c             1
c             0
c             0

How about total(1 for [category])

MF.
Title: Re: How Do I create a running total of unique values?
Post by: bonfire09 on 19 Oct 2017 08:13:35 PM
Thanks! I tried this but it did not work. Instead I brought in another column and did a running count on that grouped by the category column. IE

running-count ( [data item] for [category]) which gave counts within category, and then created a new query calculation that had a case statement that said

case

     when running_count=1 then 1
else 0

end case.