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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Duplicate in rows in the output row

Hi everybody.

 

I've got an entry flow, and I have to deplicate some rows.

More precisely, in my input there is a field that specified how many time I have to duplicate the row.

 

For exemple, my input is:

product;number

book;2

coat;0

plate;3

 

My output needs to be:

product

book

book

plate

plate

plate

 

Does anyone have any thought ?

 

Labels (2)
1 Solution

Accepted Solutions
fdenis
Master
Master


you can create an empty file,
use flowtoiterate and a tloop to add ntime the same data to the previous file.

View solution in original post

7 Replies
fdenis
Master
Master

select the max number (maybe you know it)
create a temp table like
1
2
2
3
3
3
4
4
4
4
and use tmap to join use "all row"
fdenis
Master
Master


you can create an empty file,
use flowtoiterate and a tloop to add ntime the same data to the previous file.
fdenis
Master
Master

take the max number or you may know it . Create a table or a fil containing:
122333444455555666666.....
and use a tmap to join using "all match"
TRF
Champion II
Champion II

Forget this post, other screen captures have been lost0683p000009LyFf.png

Anonymous
Not applicable
Author

1) Join your data as the Main flow to a tMap.

2) As the Lookup, join a tJavaFlex with a single int column ("number")

3) Inside the tMap, join the "number" column on your Main to the "number" column on your Lookup. Set the "Lookup Model" to "Reload at Each Row", the "Match Model" to "All Matches" and the "Join Model" to "Inner Join".

4) You will see a "globalMap Key" section appear. Click the green plus symbol and call the "globalMap Key" "count" and link your "number" column from your Main row to it.

5) Create an output table and link your "Product" record.

6) In your tJavaFlex (assuming you have already created your "number" column, add the following code to the Start Code.....

// start part of your Java code
int count = ((Integer)globalMap.get("count"));

for(int i = 0; i<count; i++){

7) Add this to your Main Code....

row18.number = count;

Note: row18 is just in my example. Yours will have to match the row name coming out of the tJavaFlex

😎 Add this to your End Code....

}

 

Your job will look like this (I'm using a tFixedFlowInput to simplify my example)....

 

0683p000009LyFk.png

 

Your tMap will something like this......

 

0683p000009Ly8k.pngWhen you run this, the row will be multiplied by the number supplied on it. If the number is 0, then no row will be output.

 

Anonymous
Not applicable
Author

Thanks everybody for your help.

 

I've impleted the fdenis's solution : 

tFlowToIterate -> tLoop -> tIterateToFlow

with in the tLoop , input.numberinto the "To" field

It's work well and the entries with (input.number == 0) are abandoned.

 

Great thanks to rhall_2_0 for your exhaustive explanation.

Your solution seems more smart and with less components; I will try it later.

Anonymous
Not applicable
Author

I've impleted this solution :

tFlowToIterate -> tLoop -> tIterateToFlow

with in the tLoop , input.numberinto the "To" field

It's work well and the entries with (input.number == 0) are abandoned.