REPT
A text repeated a number of times.
Group: Text. Compatible with DAX.
Syntax
REPT ( <text>, <num_times> )
| Parameter | Type | Description |
|---|---|---|
text | Text | The text to repeat; a number becomes text first. |
num_times | Whole number | How many times; 0 gives empty text. |
Returns
Text. The text that many times over.
Remarks
- A negative count is an error; a fraction is rounded, a half away from zero.
- A blank text gives BLANK.
- A result longer than OAX's longest text, about two million characters, is an error.
- With a measure for the count, it draws simple bars right in a table (example 2).
Examples
Repeats
EVALUATE
ROW (
"Three", REPT ( "*", 3 ),
"None", REPT ( "-", 0 ),
"Two and a half", REPT ( "ab", 2.5 ),
"A number", REPT ( 7, 3 )
)
| Three | None | Two and a half | A number |
|---|---|---|---|
| *** | (empty text) | ababab | 777 |
A bar for each product
Ten characters for the best seller, the others in proportion.
EVALUATE
ADDCOLUMNS (
VALUES ( Products[Product] ),
"Liters", [Liters sold],
"Bar", REPT ( "#", ROUND ( 10 * DIVIDE ( [Liters sold], MAXX ( ALL ( Products[Product] ), [Liters sold] ) ), 0 ) )
)
ORDER BY [Liters] DESC
| Products[Product] | Liters | Bar |
|---|---|---|
| Pils | 1004326 | ########## |
| IPA | 331884 | ### |
| Cider | 301074 | ### |
| Lettøl | 169179 | ## |
Related functions
UNICHAR, CONCATENATE, LEN, ROUND.