Forum Discussion
Anonymous
4 years agoNot applicable
How to fix column widths in a matrix where column headers change with each refresh
Hello, Can someone please help me with a solution? I have a Power BI matrix with several column fields (headers) which change whenever the data is refreshed. The auto-size option is already turned...
BerryBIA
Advocate I
2 years agoThe solution to maintain constant column widths in Power BI Table and Matrix visuals is to use the UniChar() function, Len() function and the Repeat function Rept(). You can thus build very specific widths that wont change.
Here is a complex example, checking different columns.
var Char = UNICHAR(8194)
var LENGTH = len('Table'[ReportingPeriod])
var PPSpaces = 15
var CYSpaces = 5
Return
-- Check if Reporting Period is 4 characters
IF (
Len('Table'[ReportingPeriod]) <> 4,
-- Create a 15 space string for Plan Period
Rept(Char,1) & 'Table'[ReportingPeriod]
-- Create a 15 space string for Calendar Year
,Rept (Char,5) & 'Table'[ReportingPeriod] & Rept(Char,CYSpaces)
)
Yuva969
2 years agoRegular Visitor
BerryBIA Thanks for Posting it ! I made it work with similar solution found in https://www.esbrina-ba.com/the-ultimate-hack-to-set-column-widths-in-a-matrix/ using unicode. The other issue is the Wrapped Matrix columns are getting reset inspite of Text Wrap = "On" and Auto - Width = "off".