cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
randomUser21
Helper II
Helper II

how can i do \n line break in value name in matrix

Hello everybody ,

 

how can i make a line break without touching the size of the column in a matrix, knowing that i only have values in column ?

like \n

 

everyone can help me ?

thank you

1 ACCEPTED SOLUTION

Hi , @randomUser21 

Thanks for your quick response! According to your description, you want to add \n in the column headers.

I test it in my side , the \n in Power Query Editor will not apply to Desktop.And in my workexperience , i have found no way to realize it in Power Query Editor now.

So you can just only use the UNICHAR to add the \n  in Power BI Desktop.

But also you can not put the measure as the column headers.

For your need , we can add a blank query in Power Query Editor:

vyueyunzhmsft_0-1689582700814.png

And then we can put this M code in "Advanced Editor":

 

let
    Source = Table.ColumnNames(Table),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
    #"Converted to Table"

 

 

Then we can get the column headers we need amd we need to apply the data to Desktop:

vyueyunzhmsft_1-1689582740141.png

Then we can add a caluclated column in the table.

 

Column = LEFT([Column1],7) & UNICHAR(10) & MID([Column1] ,8, LEN([Column1])-7)

 

vyueyunzhmsft_2-1689582794234.png

Then we can use this column as the headers and create a measure to return the according value.

 

Measure = IF(MAX('Query1'[Column1] )= "First description" , SUM('Table'[First description]) , SUM('Table'[Second description]))

 

vyueyunzhmsft_3-1689582838433.png

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

View solution in original post

4 REPLIES 4
randomUser21
Helper II
Helper II

hello @v-yueyunzh-msft ,
thank you for your message
sorry I expressed myself badly, I wanted this on the header of the column. in your example it was to make First \n description without modifying the length of the column

Hi , @randomUser21 

Thanks for your quick response! According to your description, you want to add \n in the column headers.

I test it in my side , the \n in Power Query Editor will not apply to Desktop.And in my workexperience , i have found no way to realize it in Power Query Editor now.

So you can just only use the UNICHAR to add the \n  in Power BI Desktop.

But also you can not put the measure as the column headers.

For your need , we can add a blank query in Power Query Editor:

vyueyunzhmsft_0-1689582700814.png

And then we can put this M code in "Advanced Editor":

 

let
    Source = Table.ColumnNames(Table),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
    #"Converted to Table"

 

 

Then we can get the column headers we need amd we need to apply the data to Desktop:

vyueyunzhmsft_1-1689582740141.png

Then we can add a caluclated column in the table.

 

Column = LEFT([Column1],7) & UNICHAR(10) & MID([Column1] ,8, LEN([Column1])-7)

 

vyueyunzhmsft_2-1689582794234.png

Then we can use this column as the headers and create a measure to return the according value.

 

Measure = IF(MAX('Query1'[Column1] )= "First description" , SUM('Table'[First description]) , SUM('Table'[Second description]))

 

vyueyunzhmsft_3-1689582838433.png

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

thank you

v-yueyunzh-msft
Community Support
Community Support

Hi , @randomUser21 

According to your description, you want to add a \n in the value in Matrix visual.

First for the value in Matrix , we can first check the "Text wrap" in the format pane to open the auto-textwrap for the value.

vyueyunzhmsft_0-1689386145291.png

And if this can not meet your need , we can also use the DAX code(   UNICHAR(10)  ) to add a "\n" for the value.

Measure = LEFT(MAX('Table'[Description]),20) & UNICHAR(10) & MID(MAX('Table'[Description]) ,21, LEN(MAX('Table'[Description]))-20)

 The result is as follows:

vyueyunzhmsft_1-1689386233907.png

For this , you can also refer to:
How to add line breaks in a string of text in DAX measure - Power BI Docs [619f-c5a9-58d-825e]

 

And if i misunderstand your need , you can also share me the sample data and your end result like a tabke format to me so that i can help you better!

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors