REPT Function DAX

REPT functions is a Power BI text function in DAX which repeats text a given number of times.



SYNTAX
REPT(<text>, <num_times>)

text

is the text that you want to repeat.

num_times

is a number which specifying the number of times to repeat text, it must be positive number.

Lets look at an example of using REPT function in Power BI.

Here we have a sample data of customer feedback, you can see customers have given a ratings out of 5.

CustomerId               Ratings

1 5
2 4
3 5
4 3
5 4
6 2
7 1
8 5
9 4
10 4
11 3
12 2


Now we will see the use of REPT function.

Lets use a REPT function to repeat a text any specified number of times.

Following measure RepeatText uses REPT function which repeats text Hello up to 5 times.

RepeatText = REPT("Hello", 5)

Once you commit the measure, lets drag it into card visual to see the output.
Lets create a simple basic report which shows the ratings given by customers in terms of visual (emojis) like if any customer has given 1 rating out of 5 then display one smiley emoji and remaining 4 will be shown as sad emoji.
Lets create a measure Rept_Rating as shown below.
Rept_Rating =
REPT ( UNICHAR ( 128513 ), CustomerFeeback[Ratings] )
& REPT ( UNICHAR ( 128530 ), 5 - CustomerFeeback[Ratings] )
You can see, REPT function repeats a Unicode number at specified number of time where number is a ratings given by customers.
To displaying emojis a UNICHAR function  is used which returns Unicode character referenced by the numeric value.
Unicode number 128513 displays a smiley emoji character and Unicode number 128530 displays a sad emoji character.
You can also use another Unicode character to make your visual look more interactive, You can get various Unicode character symbol from website – URL
Also Read..




SQL Basics TutorialSQL Advance TutorialSSRSInterview Q & A
SQL Create tableSQL Server Stored ProcedureCreate a New SSRS Project List Of SQL Server basics to Advance Level Interview Q & A
SQL ALTER TABLESQL Server MergeCreate a Shared Data Source in SSRSSQL Server Question & Answer Quiz
SQL DropSQL Server PivotCreate a SSRS Tabular Report / Detail Report
..... More.... More....More
Power BI TutorialAzure TutorialPython TutorialSQL Server Tips & Tricks
Download and Install Power BI DesktopCreate an Azure storage accountLearn Python & ML Step by stepEnable Dark theme in SQL Server Management studio
Connect Power BI to SQL ServerUpload files to Azure storage containerSQL Server Template Explorer
Create Report ToolTip Pages in Power BICreate Azure SQL Database ServerDisplaying line numbers in Query Editor Window
....More....More....More

 47 total views,  2 views today

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.