Rank in Cognos 8 development

We all know how to use the rank( ) function in cognos, it basically ranks the measure across a dimesion by weight. The basic syntax is rank([Data_Item] ASC/DESC) which will give a result set, but most of the times we need to just show top X or bottom X. For this requirement we can use
A--> running-count (rank([Data_Item] ASC/DESC))
and then add a filter like A<=X to get top X, but there is a catch here what if there are multiple rows that have the same rank and you still want to show them. In this case use
A--> running-count (rank(distinct([Data_Item] ASC/DESC))) and then a filter A<=X.
To get the bottom X try this:
A >= (maximum (running-count (rank(distinct([Data_Item] ASC/DESC)))) - X)
There are multiple ways to achive this requirement, i saw couple of other interesting ways on the net but I used this and found simple enough to share.

Comments

Post a Comment

Popular posts from this blog

Query Cognos 8/10 Content Store

Cognos 8/10 CAMID-User ID/LDAP ID report

Cognos Cross-tab Report Studio Report Ungroup Items to display as list on every line