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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Tontaube2
Helper IV
Helper IV

Shorten or lenghten column

Hi,

 

I want to determine the width of matrix-columns, which are added/ deleted by the user. The "0000000"- solution does not work as some names are longer, others are shorter.

 

I am trying to shorten or lengthen a the namesdepending on the number of chars.

 

So far I´ve created a column in Power Query "Text.PadEnd([#"Column"],15,"X")".

 

Now in DAX I want to shorten Texts to 15 Chars AND Replace "X" with the corresponding number of Unichars.

 

How do I do that? Sth. like:

 

VUColumnWidth = IF (Len([Column])>15, LEFT(FaktStruktur[Column], 15), [Basisinfo:Column] & IF ([Column]Contains "X",UNICHAR(173),[Column])"For Every X")
 
Or should I do it differently?
 
1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

So a custom column like this?

 

Text.Replace(Text.Start([Column], 15), "X", Character.FromNumber(173))

 

View solution in original post

4 REPLIES 4
Tontaube2
Helper IV
Helper IV

With that I meant "Tricking" PowerBI into using a certain number of charactes as column width, then switching auto-width off and having all columns exactly the same width.

Tontaube2
Helper IV
Helper IV

Thank you!

 

Yes...but: Don't I have to do the transformation in Dax - otherwise the "empty spaces" are deleted?

 

My goal is to have a column with names having a length of 15 chars, so that I can trick a matrix visual in having similar-length columns. The "000000"-trick is not possible since a user adds columns to compare companies.

You can do it in DAX with the same logic.

SUBSTITUTE ( LEFT ( Table1[Column], 15 ), "X", UNICHAR ( 173 ) )

I'm not sure what the "000000"-trick is.

AlexisOlson
Super User
Super User

So a custom column like this?

 

Text.Replace(Text.Start([Column], 15), "X", Character.FromNumber(173))

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors