Home » DAX » How to add line breaks in a string of text in DAX measure

How to add line breaks in a string of text in DAX measure

Add line break in DAX string

Suppose you want to display Total Sales, Total Profit & Total Discount values in single card visual as a string message.

So in order to achieve this you have to write some DAX code as given below and download dataset for this example-

DAX code-

Create a measure & write below DAX code, after that drag this measure to card visual.

Summary =
Var TotalSales = SUM('Global-Superstore'[Sales])
Var TotalProfit = SUM('Global-Superstore'[Profit])
Var TotalDiscount= SUM('Global-Superstore'[Discount])
Return
"Total Sales: " & TotalSales
& " Total Profit: " & TotalProfit
& " Total Discount: " & TotalDiscount




See the output

Card Visual String Text

Card Visual String Text

As observed in the screenshot above, all the string text is displayed in a single line. However, for improved visibility and readability, you wish to have each text value appear on a new line.

Let’s explore how you can achieve this?

  • UNICHAR(10) DAX help us to add new line between string text.
  • Turn on Word wrap for visual.

Now write a below DAX code-

Summary =
Var TotalSales = SUM('Global-Superstore'[Sales])
Var TotalProfit = SUM('Global-Superstore'[Profit])
Var TotalDiscount= SUM('Global-Superstore'[Discount])
Return
"Total Sales: " & TotalSales
& UNICHAR ( 10 ) & " Total Profit: " & TotalProfit
& UNICHAR ( 10 ) & " Total Discount: " & TotalDiscount




See the final output with new line-

UNICAHR DAX

UNICAHR DAX

Refer more DAX – DAX Tutorials

Hope you enjoyed the post. Your valuable feedback, question, or comments about this post are always welcome or you can leave us message on our contact form , we will revert to you asap.

2 thoughts on “How to add line breaks in a string of text in DAX measure”

Leave a Reply