The Repeat function can be used in both Qlik Sense and QlikView to repeat an input string a defined number of times. It can be used in both the script and a chart expression. This is how the Repeat function is defined in Qlik Sense Help:
Repeat() forms a string consisting of the input string repeated the number of times defined by the second argument.
The function takes 2 arguments. The first argument is the text that you would like to repeat. This can be a single character or a combination of many characters. It can be text defined in single quotes or a field name or variable. The second argument is the repeat count which is the number of times the first argument should be repeated. In the example measure below, the text to repeat is ‘My name is Jennell.’ along with chr(13) which represents a carriage return. The second argument is 5 indicating that this input string should be repeated 5 times.
Here are the results in a Text & image object:
Simply enough, right? In the example, the repeat count argument was set to 5 but I also could have used a variable or a numeric field to indicate the number of times the text should be repeated. Let’s look at an example that uses Repeat in the script using field names. In the script below, I am loading an inline table with a Letter field and a Number field. In the Example table that I load, I am using the Repeat function to create the RepeatExample field which will repeat the string in the Letter field the number of times specified in the Number field.
Here is a preview of the Example table once the script is executed:
By using the fields, Letter and Number, for the arguments, the Repeat function is dynamic based on the data being loaded. The Repeat function is a basic, easy-to-use function that can manipulate your data. I am sure there are many other ways this function can be used. Feel free to share how you use the Repeat function.