COGNOiSe.com - The IBM Cognos Community

Legacy Business Intelligence => COGNOS ReportNet => Report Studio => Topic started by: TCM on 16 May 2007 07:36:33 AM

Title: How can I select random records for a report
Post by: TCM on 16 May 2007 07:36:33 AM
Hi,

I currently have a report that returns a specific number of records using the rank function. The problem with that is that it always returns the same records everytime it is ran. Is it possible to return a random selection? Currently my code for returning records looks like this....

rank([CUSTOMERNUMBER])<6  

Thank you for any help you can provide!
Title: Re: How can I select random records for a report
Post by: Maple on 16 May 2007 04:06:20 PM

you can create a filter

rank([CUSTOMERNUMBER])<?value?

it will prompt you every time when you will run the report...



Title: Re: How can I select random records for a report
Post by: COGNOiSe administrator on 17 May 2007 02:55:47 AM
you have to use rank(random()). If you don't have random in FM or RS, you can add it.
Title: Re: How can I select random records for a report
Post by: TCM on 18 May 2007 10:29:08 AM
So would the code look like this to give me 50 random account numbers?

rank(random([CUSTOMERNUMBER]))<51  
Title: Re: How can I select random records for a report
Post by: COGNOiSe administrator on 18 May 2007 02:52:55 PM
random() ususally has no parameters.
Title: Re: How can I select random records for a report
Post by: TCM on 18 May 2007 03:58:58 PM
Ok, sorry for being thick headed - I'm a newbie. If there are no parameters for random, what would the code look like to get a list of 50 random accounts? I've tried the following, but neither of them worked.

rank(random()[CUSTOMERNUMBER])<51
rank(random([CUSTOMERNUMBER]))<51
Title: Re: How can I select random records for a report
Post by: COGNOiSe administrator on 21 May 2007 07:32:39 PM
No worries, matey!

First, do you have random function available in Report Studio, meaning can you select it from the list of available functions for a DataItem calculation. If NO, please find instructions on how to add a custom database function.

Then follow with creating a calculation of this form for your filter: rank(random())<51

I think it should work.