OpenBI Docs Buy

REPT

A text repeated a number of times.

Group: Text. Compatible with DAX.

Syntax

REPT ( <text>, <num_times> )
ParameterTypeDescription
textTextThe text to repeat; a number becomes text first.
num_timesWhole numberHow 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 )
)
ThreeNoneTwo and a halfA number
***(empty text)ababab777

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]LitersBar
Pils1004326##########
IPA331884###
Cider301074###
Lettøl169179##

UNICHAR, CONCATENATE, LEN, ROUND.

Last updated · OpenBI Studio 0.3.74