Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
klikgevoel
Contributor III
Contributor III

Repeat records based on variable value

Currently I have trouble in finding the solution for a repeater within Qlik. Using For each or For I cannot seem to get it working. 

Assume the following set

Repeater:
Load * Inline [
Name,RepeatMe,Start,End
Bill,1,1,1
Maria,7,1,
Chris,4,2,5
Jennifer,6,2,
];

What I want is a repeater, that repeats the records inside the table based on the variable RepeatMe. The variable Start dictates when the repeater starts with its count, and the variable End is used to put the value at the last repeated record. If End has a null, in the case of Maria and Jennifer, there is no value in End. See image below for output. Thanks in advance!

repeatme_ideal_solution.PNG

 

 

Labels (5)
1 Solution

Accepted Solutions
tresesco
MVP
MVP

Here you go.

Repeater:
Load
	Name,
	Start+IterNo()-1 as Start,
	If(Start+IterNo()-1=End, End) as End
While IterNo()<=RepeatMe;	
	
Load * Inline [
Name,RepeatMe,Start,End
Bill,1,1,1
Maria,7,1,
Chris,4,2,5
Jennifer,6,2,
];

tresesco_0-1593598745194.png

 

View solution in original post

2 Replies
tresesco
MVP
MVP

Here you go.

Repeater:
Load
	Name,
	Start+IterNo()-1 as Start,
	If(Start+IterNo()-1=End, End) as End
While IterNo()<=RepeatMe;	
	
Load * Inline [
Name,RepeatMe,Start,End
Bill,1,1,1
Maria,7,1,
Chris,4,2,5
Jennifer,6,2,
];

tresesco_0-1593598745194.png

 

klikgevoel
Contributor III
Contributor III
Author

Elegant solution! Many thanks!