jschlereth
jschlereth

Reputation: 1091

Is there a way to add line breaks in a string of text in Microsoft's DAX language?

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!

Upvotes: 10

Views: 61041

Answers (7)

Matt Ritchie
Matt Ritchie

Reputation: 783

I wanted to add this for my own purposes. I found that i could add unichar(10) into the delimiter to give me exactly what i needed. I also found the size of the visual was affecting the layout

@FilterServices = 
CONCATENATEX(
    VALUES(Services[cr7c3_servicedescription]),  -- The column with multiple selected values
    Services[cr7c3_servicedescription] ,          -- The expression to concatenate (e.g., [Product Name])
    UNICHAR(10)                    -- The delimiter (e.g., comma and space)
)

Upvotes: 0

Seyma Kalay
Seyma Kalay

Reputation: 2861

Was looking for the same thing and I came across with ` & UNICHAR ( 10 ) & in here

Upvotes: 0

KARTHIKEYAN.A
KARTHIKEYAN.A

Reputation: 20108

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

enter image description here

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

enter image description here

Upvotes: 2

Beth Hall
Beth Hall

Reputation: 121

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

Upvotes: 12

S. Mendez
S. Mendez

Reputation: 33

The one that worked for me is <br/>.

Do something like this:

String = CONCATENATE(CONCATENATE("HEADER","<br/>"),"BODY")

The espected output is:

HEADER
BODY

Upvotes: -4

nguyen giang
nguyen giang

Reputation: 109

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
",
"
)

Upvotes: 10

Christian
Christian

Reputation: 7

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

Upvotes: -1

Related Questions