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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
mf123
Frequent Visitor

how to enter space for power bi matrix with c# string

i use microsoft power bi to generate reports for my business, and i use the matrix visual, and i want to make all columns the same width so  i add a line break after every 25 characters in my c# app,but i don't want to break a word, so if when i add a new word to the line.the line will be greater from 25 characters i make the line break before this word , so some columns have only  lines that is max 23 characters  and some 22 characters, so not all columns have the same width, so i try to add whitespace to the end of the line to be the size of 25 characters with mystring.PadLeft(10) but it's not working in power bi trim it,
(i can't use the setting to not auto-size-width of the columns, because my columns headers are not static)

if anyone have a idea how to solve it 

2 REPLIES 2
AllisonKennedy
Super User
Super User

@mf123  the do not auto-size setting should still work if the column names change, just not if the number of them changes I think?? https://www.purplefrogsystems.com/blog/2021/04/how-to-make-your-matrix-column-widths-all-equal-to-ea... 

 

Otherwise try using UNICHAR to add the white space?

 

Also, are you using a font that's got the same width for each character?


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

i try already, but if i add by my other system new collums and rows when i open the report and the collums with the new headers,the collums  get the width of the rows even i set auto-size-width to off

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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