Home » DAX » DAX REPT Function

DAX REPT Function

REPT DAX Power BI

The REPT DAX function is used to repeat text a given number of times. Its comes under DAX TEXT functions category.

Syntax

REPT(<text>, <num_times>) 

Parameters

text – The text you want to repeat.

num_times – A positive number specifying the number of times to repeat text.

Let’s get started

Step-1: Create a measure with below DAX.

Rept = REPT("Hi", 4)

Step-2: Now drag one card visual into Power BI canvas to see the REPT result.

Rept DAX function

REPT DAX function



REPT DAX function another example-

Import below Hotel feedback ratings dataset into Power BI desktop-

Category Ratings
Front office Staff 5
Ambiance 4
Restaurant Staff 4
Travel Desk 3
House Keeping 4
Food 5
Fitness Center 5
Cleanliness of the room 2

Now follow these steps-

Step-1: Add one column( Right click on dataset > select New column) and write below DAX code-

Ratings with emoji =

REPT( UNICHAR ( 128077 ), feedback[Ratings])

& REPT ( UNICHAR ( 128078 ), 5 – feedback[Ratings] )

Step-2: Here, Unicode no 128077 display Thumps up sign & 128078 display Thumps down sign, You can refer this site for more Unicode characters – https://unicode-table.com/en/emoji/.

REPT DAX function example

REPT DAX function example



Step-3: See the final result.

REPT with UNICHAR DAX

REPT with UNICHAR DAX

Note

  • If number_times is 0 (zero), REPT returns a blank.
  • If number_times is not an integer, it is truncated.
  • The REPT function result cannot be longer than 32,767 characters, or REPT returns an error.





Refer DAX post:- DAX Tutorials

Hope you enjoyed the post. Your valuable feedback, question, or comments about this post are always welcome or you can leave us message on our contact form , we will revert to you asap.

Leave a Reply