If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

How can I select random records for a report

Started by TCM, 16 May 2007 07:36:33 AM

Previous topic - Next topic

TCM

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!

Maple


you can create a filter

rank([CUSTOMERNUMBER])<?value?

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




COGNOiSe administrator

you have to use rank(random()). If you don't have random in FM or RS, you can add it.

TCM

So would the code look like this to give me 50 random account numbers?

rank(random([CUSTOMERNUMBER]))<51

COGNOiSe administrator


TCM

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

COGNOiSe administrator

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.