COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: que1983 on 12 Feb 2017 07:17:58 PM

Title: Flagging repeat rows and adding color
Post by: que1983 on 12 Feb 2017 07:17:58 PM
In a report studio query I have as an example the field
Loan Number 
1111
1112
1113
1113
1114

If loan number is repeated on the next row (in this case 1113)  I want to flag both by highlighting the background with a color yellow
Can that be done in cognos report studio in properties
Title: Re: Flagging repeat rows and adding color
Post by: BigChris on 13 Feb 2017 02:06:10 AM
I'd probably try experimenting with a running-count calculation, coupled with a conditional format
Title: Re: Flagging repeat rows and adding color
Post by: hespora on 13 Feb 2017 02:22:42 AM
Exactly what BigChris said:


running-count(
  [any measure you have available]
  for [Loan Number]
)


Then, format on [running-count] > 1. Do note however that this will flag different rows depending on how you have sorted your output.
Title: Re: Flagging repeat rows and adding color
Post by: Lynn on 13 Feb 2017 03:13:09 AM
The difficulty with running-count is that you can only flag the second or subsequent repeated values, not the first. The first one will have a running-count of 1 so you can't tell if it is a distinct value or just the first one of two or three or more.

Since que1983 indicated that both repeated values need to be highlighted, it might be worth experimenting with the count() function. The below expression will give the count of loan numbers on the layout (1 for each row) and then total them with loan number as the scope. For the example given, this should return a value of 1 for first, second, and fifth rows while third and fourth rows would return 2.

Conditionally style for values > 1 to highlight all the duplicated rows.


total ( count ( [Loan Number]  ) for [Loan Number] )


All this assumes we are talking about a relational model.
Title: Re: Flagging repeat rows and adding color
Post by: BigChris on 13 Feb 2017 03:52:46 AM
Lynn's right, I'm wrong...'nuff said.
Title: Re: Flagging repeat rows and adding color
Post by: Lynn on 13 Feb 2017 08:55:11 AM
Quote from: BigChris on 13 Feb 2017 03:52:46 AM
Lynn's right, I'm wrong...'nuff said.

Nothing wrong with providing multiple approaches to consider! Chances are that que1983 and other interested parties who happen across the thread will learn a couple of new things in any case.
Title: Re: Flagging repeat rows and adding color
Post by: Lynn on 14 Feb 2017 03:08:07 AM
que1983 wrote in a personal message:

Quote
Conditionally style for values > 1 to highlight all the duplicated rows.


Code: [Select]

total ( count ( [Loan Number]  ) for [Loan Number] )

I used your code in a data item called count1  When I run it I get large numeric counts (not a 1 or 2) which you mentioned in your reply.  I get something like
Loan Number        count1
1111                     5999
1112                     5200
1113                     6444
1113                     6444
1114                     5688
Isnt your code supposed to assign a 1 if not repeated or a 2 if repeated.  I tried experimenting with aggregation however I get the same results


Maybe others can assist further as my time is limited today. Always better to post to the thread rather than personal messages because not everyone is free all the time and certainly others benefit by keeping conversations in the forum.

I mocked up an example using the GO Sales (query) package but your source and granularity might be different. Perhaps count distinct might be the ticket. You didn't confirm if your source is relational or dimensional - none of what I posted is applicable for dimensional.

If you solve the problem try to take a moment and post back so that others in the future with a similar problem might benefit.