REPT DAX Function (Text)
Repeats text a given number of times. Use REPT to fill a cell with a number of instances of a text string.
Syntax
Parameter | Attributes | Description |
---|---|---|
Text |
The text you want to repeat. |
|
NumberOfTimes |
A positive number specifying the number of times to repeat text. |
Return values
A string containing the changes.
Remarks
If NumberOfTimes is 0 (zero), REPT returns an empty string.
If NumberOfTimes is not an integer, it is rounded to the closest integer.
The result of the REPT function cannot be longer than 32,767 characters, or REPT returns an error.
Examples
-- REPT repeats a string for a given number of times DEFINE MEASURE Customer[Cars] = REPT ( "?", SELECTEDVALUE ( Customer[Cars Owned] ) ) EVALUATE CALCULATETABLE ( TOPN ( 8, SUMMARIZECOLUMNS ( Customer[Customer Name], "Cars", [Cars] ), Customer[Customer Name], ASC ), Customer[Customer Name] <> "" ) ORDER BY Customer[Customer Name]
Customer Name | Cars |
---|---|
Adams, Aaron | ? |
Adams, Adam | ?? |
Adams, Alex | ? |
Adams, Alexandra | ? |
Adams, Allison | |
Adams, Amanda | ? |
Adams, Amber | ? |
Adams, Andrea | ??? |
Related articles
Learn more about REPT in the following articles:
-
Handling customers with the same name in Power BI
This article explains how to show different customers with the same name in a Power BI report by using zero-width spaces, thus simplifying the presentation without adding visible characters to make the names unique. » Read more
-
Sorting duplicated names in a level of a hierarchy with DAX
This article describes how to use DAX calculated columns to sort names that look like duplicates at a certain level of a hierarchy, but are unique when considering their full path within the hierarchy. » Read more
Last update: Dec 4, 2024 » Contribute » Show contributors
Contributors: Alberto Ferrari, Marco Russo
Microsoft documentation: https://docs.microsoft.com/en-us/dax/rept-function-dax