Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
Jennell_McIntire
Employee
Employee

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.

 

Syntax:

 

Repeat(text[, repeat_count])

 

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.

 

name.png

 

Here are the results in a Text & image object:

 

jennell.png

 

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.

 

script.png

 

Here is a preview of the Example table once the script is executed:

 

table.png

 

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.

 

Thanks,

Jennell

7 Comments
sandeeps_hyd
Contributor II
Contributor II

@Jennell_McIntire wrote:

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.

 

Syntax:

 

Repeat(text[, repeat_count])

 

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.

 

name.png

 

Here are the results in a Text & image object:

 

jennell.png

 

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.

 

script.png

 

Here is a preview of the Example table once the script is executed:

 

table.png

 

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.

 

Thanks,

Jennell


Hi Jennel,

Is it possible to get decimal / precision repetitions  like in the below example?

Ex:

Repeat( ' * ', rating )  (Say rating = 4.5)

Thanks.

0 Likes
6,146 Views
sandeeps_hyd
Contributor II
Contributor II

Also, please let me know if there exists any other function?

0 Likes
6,146 Views
arielrodrigues
Contributor II
Contributor II

Is it possible to do that with images in the table expression?

Example: Repeat('C:\Imagens\Yellow Star.png',5)

2,964 Views
Anil_Babu_Samineni

@arielrodrigues  You can choose, May be ASCII keyword to deserve this

Repeat(Chr(<Your number>), 5)

2,936 Views
arielrodrigues
Contributor II
Contributor II

@Anil_Babu_Samineni thanks for your answer.

I've tried that, but the half star doesn't fit in chr(), I guess. I "googled" it but I had no success. 

There are only two simple types of stars: The filled one and the empty, and .

Unfortunately, I didn't find the half star. It pastes like a rectangle. 

2,905 Views
Anil_Babu_Samineni

@arielrodrigues  Is this for some ratings with 4 stars and half star for 4.5 rating?

0 Likes
2,877 Views
arielrodrigues
Contributor II
Contributor II

@Anil_Babu_Samineni  Yup!

To pass through that difficulty I needed to do this way:

arielrodrigues_0-1627502483222.png

I made in Photopea each image:

arielrodrigues_1-1627502700620.png

... and that's the way I found to show the stars in the table LOL

 

 

0 Likes
2,847 Views