Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
BeaBF
Memorable Member
Memorable Member

Concat strings and indentation in Matrix

Hello everyone!

I need your help to solve a problem. I need to insert two concatenated fields, namely Description and Code, as rows in a Power BI matrix. I would like the Code to be properly aligned as if it were in a separate column from the Description, even though they are actually in the same column.

I've tried different codes, some work in a table, but when dragged into the matrix, they appear misaligned.

Do you have any ideas? Thank you very much.

 

As-is:

BeaBF_0-1685084813703.png

 

 

 

 

1 ACCEPTED SOLUTION
barritown
Super User
Super User

Hi @BeaBF

 

First of all, you must use a monospace font (Courier New, for example).

 

Secondly, you must switch off the "Word wrap" option in the "Row headers" setting of the Matrix visual (see this solution - https://community.fabric.microsoft.com/t5/Desktop/Keep-spaces-in-column-fields-when-using-table-matr...).

 

Then everything works with a calculated column like this:

barritown_0-1685095106148.png

And the same in plain text:

LIV_5 = 
VAR MinIdent = 1
VAR MaxLen = MAXX ( ALL ( data ), LEN ([Description] ))
VAR QtyExtraSpaces = MaxLen - LEN ( [Description] ) + MinIdent
RETURN [Description] & REPT (UNICHAR(32), QtyExtraSpaces ) & CONVERT ( [Code], STRING )

 

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

View solution in original post

3 REPLIES 3
barritown
Super User
Super User

Hi @BeaBF

 

First of all, you must use a monospace font (Courier New, for example).

 

Secondly, you must switch off the "Word wrap" option in the "Row headers" setting of the Matrix visual (see this solution - https://community.fabric.microsoft.com/t5/Desktop/Keep-spaces-in-column-fields-when-using-table-matr...).

 

Then everything works with a calculated column like this:

barritown_0-1685095106148.png

And the same in plain text:

LIV_5 = 
VAR MinIdent = 1
VAR MaxLen = MAXX ( ALL ( data ), LEN ([Description] ))
VAR QtyExtraSpaces = MaxLen - LEN ( [Description] ) + MinIdent
RETURN [Description] & REPT (UNICHAR(32), QtyExtraSpaces ) & CONVERT ( [Code], STRING )

 

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

Hi @barritown!
First of all, thank you very much for your help. It's just what I had already implemented, with a slightly different formula but returning the same output.

I realized from your answer that the problem is the font, but I have a mandatory font to use.

Do you know if there is any resolution for this problem?


Hi @BeaBF,

Unfortunately, without a monospace font the problem seems to me unsolvable. I hoped to solve it with the help of the tabulation symbol instead of extra spaces but it doesn't work.  

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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