Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
shahafei2
Creator
Creator

Need help to load first N orders for each datestmp

I'm loading QVD that similar to this one:

Datestamp               |  Year |   Month  | Day |  WeekDay | Hour | OrderNumber

01/01/2017 14:00   | 2017  |  Jun       | 01   |  Friday       | 14     | 1

01/01/2017 14:00   | 2017  |  Jun       | 01   |  Friday       | 14     | 2

01/01/2017 14:00   | 2017  |  Jun       | 01   |  Friday       | 14     | 3

01/01/2017 14:00   | 2017  |  Jun       | 01   |  Friday       | 14     | 4

01/01/2017 15:00   | 2017  |  Jun       | 01   |  Friday       | 15     | 1

01/01/2017 15:00   | 2017  |  Jun       | 01   |  Friday       | 15     | 2

01/01/2017 15:00   | 2017  |  Jun       | 01   |  Friday       | 15     | 3

01/01/2017 15:00   | 2017  |  Jun       | 01   |  Friday       | 15     | 4

how could i load first 2(Dynamic Number) orders for each datestmp

for example:

DateStamp               |  Year |   Month  | Day |  WeekDay | Hour | OrderNumber

01/01/2017 14:00   | 2017  |  Jun       | 01   |  Friday       | 14     | 1

01/01/2017 14:00   | 2017  |  Jun       | 01   |  Friday       | 14     | 2

01/01/2017 15:00   | 2017  |  Jun       | 01   |  Friday       | 15     | 1

01/01/2017 15:00   | 2017  |  Jun       | 01   |  Friday       | 15     | 2

9 Replies
vishsaggi
Champion III
Champion III

What is your Load script can you share? And you mean you dont want to get ordernumber 3 and 4?

If yes, then use like:

LOAD *

FROM yourqvdpath\qvdname.qvd(qvd)

WHERE Not Match(OrderNumber, 3, 4);

vinieme12
Champion III
Champion III

try below

temp:

LOAD *,AutoNumber(Datestamp&OrderNumber,Datestamp) as RECGROUP inline [

Datestamp               ,  Year ,   Month  , Day ,  WeekDay , Hour , OrderNumber

01/01/2017 14:00   , 2017  ,  Jun       , 01   ,  Friday       , 14     , 1

01/01/2017 14:00   , 2017  ,  Jun       , 01   ,  Friday       , 14     , 2

01/01/2017 14:00   , 2017  ,  Jun       , 01   ,  Friday       , 14     , 3

01/01/2017 14:00   , 2017  ,  Jun       , 01   ,  Friday       , 14     , 4

01/01/2017 15:00   , 2017  ,  Jun       , 01   ,  Friday       , 15     , 1

01/01/2017 15:00   , 2017  ,  Jun       , 01   ,  Friday       , 15     , 2

01/01/2017 15:00   , 2017  ,  Jun       , 01   ,  Friday       , 15     , 3

01/01/2017 15:00   , 2017  ,  Jun       , 01   ,  Friday       , 15     , 4

];

NoConcatenate

FACT:

load * Resident temp

Where RECGROUP <=2;

Drop table temp;

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
shahafei2
Creator
Creator
Author

My Problem it's that each ordernumber have differnt INT

(4430776534,654219876 and not 1,2,3,4)

i have more than 1M orders and the relevant information is the first 400

so i can't use the where functaion for <=400

Anil_Babu_Samineni

Even if you have 1 M records Autonumber can fetch only 2 order numbers. Have you tried atleast which Vineet provides

If you tried, Can you provide live data

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
vinieme12
Champion III
Champion III

Which is exactly why we've used  Autonumber()

Try the script first and see

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
shahafei2
Creator
Creator
Author

I didn't understand how to create inline per 1M orders

as much as I know when I'm creating inline I have to enter the data itself

could i use existing fields from previous table?

If I understood it right ,could I use RowNu() function that will reset itself each time that the date stamp field will changed ? and than I believe I could use it (Where RowNo<=400)? 

If so how could I force to reset the RowNo() each time the script recognize new date stamp?

vinieme12
Champion III
Champion III

That inline load was just to show you how it works

Your actual script would be like below

Temp:

Load

*,

Autonumber (datestamp&order no, datestamp)  as Recgroup

From yoursourcexxxxx;

NOCONCATENATE

FACT:

load * Resident temp

Where Recgroup <=n;  

Drop Table temp;

This will load first n records for each datestamp

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
shahafei2
Creator
Creator
Author

Thank you I'll try it

shahafei2
Creator
Creator
Author

It worked thank you