I have a DAX function that pulls in multiple strings of text (from multiple columns) into one cell. But on display I want to have a line break in between the header and the body of the paragraph. Is there a way to code in a line break with DAX? FYI, I'm using Power BI for this. Thanks!
5 Answers
Using DAX String = [field A] & UNICHAR(10) & [field B]
Example: Field A contains text: January 11, 2018 Field B contains text: Happy Birthday Elvis
This will return:
January 11, 2018
Happy Birthday Elvis

- 121
- 1
- 2
In BI Desktop, just type alt-enter in your DAX formula to add new line For example:
CONCATENATEX(Project, ProjectName & ":" & [some-measure],
//new line in parameter delimiter
",
"
)

- 109
- 1
- 3
-
This is a good solution for this, but using Variables is recommended in the DAX Formula as it can be used multiple time. Find an example here: https://community.powerbi.com/t5/Desktop/how-to-get-text-in-new-line-in-the-data-cards-label/m-p/441556/highlight/true#M203915 – Gangula Jul 14 '19 at 18:32
First, we have to create string concatenation using CONCATENATE() method, then use UNICHAR(10) to create space between strings
Product Sold Count =
VAR Valuel = "Product Sold"
VAR Value2 = "Today : " & (
CALCULATE(
SUMX(
FILTER(
'api_Product Sold',
'api_Product Sold'[Date] = TODAY()
),
'api_Product Sold'[Count]
)
)
+ 0 )
VAR Value3 = "Total : " & (
CALCULATE(
SUMX(
FILTER(
'api_Product Sold',
'api_Product Sold'[Date] <= TODAY()
),
'api_Product Sold'[Count]
)
)
+ 0 )
VAR FirstCONCATENATE = CONCATENATE(CONCATENATE(Valuel,UNICHAR(10)),Value2)
VAR SecondCONCATENATE = CONCATENATE(CONCATENATE(Value2,UNICHAR(10)),Value3)
RETURN SecondCONCATENATE
Once your string is ready then select card chat and assign the measure created
Where height of the card chart should be proper then only word wrap will work and before it should be enable the word wrap property on format tab

- 18,210
- 6
- 124
- 133
The PowerqueryFormulaReference uses in the Lines.ToText example something like
#(cr)#(lf)
I added this as a string (!) to my text and it worked...

- 7
- 1
-
2I hate to split hairs (especially in a discussion about concatenation:-) ) but PowerQuery is not DAX. The question seems to be specifically about DAX. – DatumPoint Jun 07 '18 at 01:23
The one that worked for me is <br/>
.
Do something like this:
String = CONCATENATE(CONCATENATE("HEADER","<br/>"),"BODY")
The espected output is:
HEADER
BODY

- 9,013
- 5
- 30
- 31

- 33
- 6
just gave me "\n\r and
" respectively in the text field.... – jschlereth Mar 10 '16 at 15:43