REPT functions is a Power BI text function in DAX which repeats text a given number of times.
SYNTAX REPT(<text>, <num_times>)
text
is the text that you want to repeat.
num_times
is a number which specifying the number of times to repeat text, it must be positive number.
Lets look at an example of using REPT function in Power BI.
Here we have a sample data of customer feedback, you can see customers have given a ratings out of 5.
CustomerId        Ratings
1
5
2
4
3
5
4
3
5
4
6
2
7
1
8
5
9
4
10
4
11
3
12
2
Now we will see the use of REPT function.
Lets use a REPT function to repeat a text any specified number of times.
Let’s create a new column named RepeatText that uses the REPT function which repeats text Hello up to 5 times.
RepeatText = REPT("Hello", 5)
Once you commit the DAX, lets drag it into card visual to see the output.
Lets see one more example, assume that you have to create a simple basic report which shows the ratings given by customers in terms of visual (emojis) such as if any customer has given 1 rating out of 5 then display one smiley emoji and remaining 4 will be shown as sad emoji.
Lets create a new column named Rept_Rating as shown below.
Once you commit DAX, just drag it into visual to see the output.
You can see, REPT function repeats a Unicode number at specified number of time where number is a ratings given by customers.
To displaying emojis a UNICHAR function is used which returns Unicode character referenced by the numeric value.
Unicode number 128513 displays a smiley emoji character and Unicode number 128530 displays a sad emoji character.
You can also use another Unicode character to make your visual look more interactive, You can get various Unicode character symbol from website – URL