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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
JaneYu
Contributor III
Contributor III

how to get top 5 for each customer from a flat file

There is a flat file with CustomerID, OrderDate, SalesAmount.

Each customer can have multiple orders. The report will get the recent 5 orders for each customer.

It is easy to do in SQL, but the source is a flat file and the data will not be loaded to SQL database.

 

Is there any way in Talend to apply this scenario? Thank you very much for your help.

(if a new column RowNumber is added to the data flow and the value is set to 1,2,3,4,5,...for each customer, then a tFilterRow can get the records with RowNumber<=5

how to write java code in the tjavaflex?)

CustomerID Order Date SalesAmount
1 8/23/2017 6.6
1 8/11/2017 6.6
1 8/7/2017 6.6
1 7/29/2017 6.6
1 7/23/2017 6.6
1 7/16/2017 6.6
1 7/3/2017 6.6
1 8/23/2017 6.6
1 7/23/2017 6.6
2 6/23/2017 6.6
2 4/23/2017 6.6
2 1/23/2017 6.6
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi,

Yes with tJavaFlex it's look like fine . Your code can be like :

 

TFileInput ---row11--- tJavaFlex --- row12 --- tlogrow

 

0683p000009LvsN.png

 

Don't Forget to add a column to your tJavaFlex output schema.

This will be work but you have maybe some special code to limit case like first and last line

 

Good luck

SGV

View solution in original post

2 Replies
Anonymous
Not applicable

Hi,

Yes with tJavaFlex it's look like fine . Your code can be like :

 

TFileInput ---row11--- tJavaFlex --- row12 --- tlogrow

 

0683p000009LvsN.png

 

Don't Forget to add a column to your tJavaFlex output schema.

This will be work but you have maybe some special code to limit case like first and last line

 

Good luck

SGV

JaneYu
Contributor III
Contributor III
Author

SGV: thank you for your reply. Your solution works like magic.