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.
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.
Thanks for your posting,many people are approaching for Cognos online training
ReplyDelete