Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
We are aware of an issue with the Product Downloads page and looking into it.
cancel
Showing results for 
Search instead for 
Did you mean: 
MK_QSL
MVP
MVP

Random Data

Can someone post a script to generate random sales data in qlikview...

What i need is

Customer Name,

Invoice Date

Invoice Value

Invoice Number.....etc

Labels (1)
1 Solution

Accepted Solutions
swuehl
Champion III
Champion III

Just replace the factor for RAND() function with the number of days in your interval:

Date(makedate(2012,1,1)+floor(RAND()*(makedate(2013,12,31)-makedate(2012,1,1)+1))) as InvoiceDate,

View solution in original post

7 Replies
IAMDV
Master II
Master II

Hi Manish,

You can make up the data using QlikView functions like Rand(), Autogenerate and other Date functions. Something like this...

LOAD

Floor(Rand() * 10000) AS [Invoice Value]

AutoGenerate 10;


You can add whatever you need for [Customer Name]. Or you can also check this website where you can find loads of free data.


http://www.infochimps.com/tags/sales


Cheers,

DV


www.QlikShare.com

Not applicable

Use Shortcut key Ctrl +Q in Script Editor.... Random Load code will be generated...and then modify it as required...

Thanks,

Selva

swuehl
Champion III
Champion III

You can use the RAND() function to generate random values:

LOAD

'Customer'&Ceil(RAND()*100) as CustomerName,

Date(makedate(2012)+floor(RAND()*(2*365+1))) as InvoiceDate,

round(RAND()*1000+50,10) as InvoiceValue,

recno() as InvoiceNo

autogenerate 1000;

MK_QSL
MVP
MVP
Author

Thanks for your reply.

Can you specify below

floor(RAND()*(2*365+1)))

Is there any speciallogic of 2*365+1?

Edit : also what if I need dates between 01/01/2012 to today?

swuehl
Champion III
Champion III

No, no special logic. It just creates values in the range of 2 years including a leap year (to add upon start date 2012 Jan 1st).

MK_QSL
MVP
MVP
Author

What if I need to create random dates between two specific dates?

swuehl
Champion III
Champion III

Just replace the factor for RAND() function with the number of days in your interval:

Date(makedate(2012,1,1)+floor(RAND()*(makedate(2013,12,31)-makedate(2012,1,1)+1))) as InvoiceDate,