Dax Function: REPT

Category: Text Functions

The REPT function in Power BI is a DAX (Data Analysis Expressions) function that repeats a text string a specified number of times. It is primarily used to generate patterns, create text visualizations, or format data.

Purpose

  • Text Pattern Creation: Generate repeated text patterns dynamically.
  • Visualization Enhancement: Use repeated text for visual indicators such as progress bars or ratings.
  • Data Transformation: Standardize text lengths by padding or replicating characters.

Type of Calculations

The REPT function performs scalar text transformations. It concatenates a text string with itself for a specified number of repetitions.

Practical Use Cases

  1. Generate Progress Indicators: Create text-based progress bars for numeric values (e.g., repeat “|” to indicate progress level).
  2. Formatting Output: Pad text fields for alignment or consistency.
  3. Visualization Labels: Use stars (★) or other symbols to represent ratings.

REPT(<text>, <number_of_times>)</number_of_times></text>

 
ParameterTypeDescription
textText/ColumnThe text string to be repeated.
number_of_timesIntegerThe number of times the text string should be repeated. Must be >= 0.


How Does REPT
 Dax Function Works

  • The REPT function takes a text string and an integer as inputs.
  • It concatenates the text string with itself repeatedly based on the value of number_of_times.
  • The resulting text string has a length equal to the length of the input text multiplied by the number of repetitions.

What Does It Return?

The function returns a text string with the input text repeated the specified number of times. If the input is blank or the number of times is zero, it returns an empty string.

When Should We Use It?

  • To create dynamic patterns or text-based visual aids.
  • To ensure consistent formatting in text fields.
  • When visualizing or emphasizing numerical data with repeated characters.

Examples

Basic Usage – Repeat a String:


REPT("A", 5)

Result: "AAAAA"

Column Usage – Create Progress Bars:


ProgressBar = REPT("|", INT(Sales[CompletionPercentage] / 10))

Generates a progress bar where each “|” represents 10% completion.

Advanced Usage – Combine with Other Functions:


RatingStars = REPT("★", Customers[Rating]) & REPT("☆", 5 - Customers[Rating])

Creates a star rating visualization by combining solid and empty stars.

Tips and Tricks

  • Use INT or ROUND functions to ensure the repetition count is a whole number.
  • Avoid excessive repetition counts, as long strings may impact performance.
  • Pair with LEN to dynamically adjust repetitions based on text length.

Performance Impact of REPT DAX Function:

  • Efficient for small-to-medium text transformations.
  • Repeating very large text strings or high repetition counts may slow down performance, especially in large datasets.

Related Functions You Might Need

  • CONCATENATE: Combine two text strings into one.
  • LEN: Measure the length of a text string.
  • FORMAT: Format numbers or dates for text representation.

Want to Learn More?
For more information, check out the official Microsoft documentation for REPT You can also experiment with this function in your Power BI reports to explore its capabilities.

Unlock the full capabilities of Power BI and elevate your data insights with our specialized consulting services. Whether you need guidance on advanced DAX functions like those highlighted here, support in designing interactive dashboards, or expertise in optimizing data models for enhanced performance, our experienced Power BI consultants are equipped to deliver customized solutions for your business. Explore our Power BI Consulting Services page to discover how we can help your organization make smarter, data-driven decisions.

1. What does the REPT function do in Power BI?

The REPT function repeats a specified text string a given number of times.

2. What happens if the repetition count is zero in the REPT function?

The function returns an empty string.

3. Can the REPT function handle dynamic repetition counts?

Yes, the repetition count can be calculated dynamically using other DAX functions.

4. Is there a limit to the repetition count in the REPT function?

While there is no explicit limit, excessively large repetition counts can impact performance.

5. How can I use the REPT function for progress bars?

Use REPT with symbols like “|” or “•” to represent progress visually. Combine it with a numeric value for dynamic lengths.