n1k31t4
n1k31t4

Reputation: 2874

Concatenate text with newlines in PowerBI

If I have a column in a table where each cell contains text, how can I push them as output into e.g. a card and separate the cells with a new line?

I have been using the CONCATENATEX function, which takes a delimiter argument; however the standard new line character ('\n') doesn't work.

Upvotes: 4

Views: 36370

Answers (3)

Andrew Watts
Andrew Watts

Reputation: 11

Substitute /n with the string "#(cr)#(lf)" to create a new line.

Upvotes: 0

benik9
benik9

Reputation: 191

In the concatenate code, if you insert a "shift + enter" after the comma, it gives me a line break, without breaking the code.

Example:

'Query1'[LetterCode],
 ",<Inserted SHIFT-ENTER here>
 ", 
'Query1'[LetterCode],

Upvotes: 1

n1k31t4
n1k31t4

Reputation: 2874

It is possible to pass Unicode characters to the CONCATENATEX function, using the UNICHAR(number) function.

The number parameter corresponds what looks to be the decimal UTF-16 or UTF-32 encodings (as shown here).

This means a new line is given by UNICHAR(10).

A final solution might then be: CONCATENATEX(TableName, TableName[TextColumn], UNICHAR(10))

Here is a screenshot that shows:

  • the input table in Excel (top left)
  • The table once imported into Power BI Desktop (top right)
  • The Measure 'Description' and the output within a Card object (bottom)

enter image description here

In the last line of the Measure code, marked yellow, you can see the use of UNICHAR(10) as a new line separator.

If nothing were to be selected in the Slicer object (i.e. everything is selected by default - no filter is used), then "Show other text" would be displayed in the Card.

Upvotes: 8

Related Questions