Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a script that is generating random sales data between 1500 and 5000 for a range of dates as below...
TmpSalesData:
LOAD
Date($(varMinDate) + RowNo() - 1) AS DateKey,
rand()*3500 + 1500 AS RandomData
AUTOGENERATE ($(varMaxDate) - $(varMinDate)+1);
I also have a field called OUTLET in a previously loaded table. I would like to amend my script for the TmpSalesData table using FOR .. NEXT to generate random data for each combination of Date and OUTLET. I have tried a few combinations of FOR .. NEXT within and outside the load statement without success. Could someone please point me in the right direction?
Many thanks
Dave
Assume previously loaded table OUTLET with a field named "Outlet". Use NoOfRows('OUTLET') as the limit variable. Use peek() as the index.
Suggested code (untested)
FOR i = 0 TO NoOfRows('OUTLET') - 1
TmpSalesData:
LOAD
peek('Outlet', $(i), 'OUTLET') as Outlet,
Date($(varMinDate) + RowNo() - 1) AS DateKey,
rand()*3500 + 1500 AS RandomData
AUTOGENERATE ($(varMaxDate) - $(varMinDate)+1);
NEXT
-Rob
Many thanks Rob, that is perfect.
Regards
Dave