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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
andyor
Resolver I
Resolver I

Making font wrap work correctly for matrix column headers?

I have some column headers as such. 

 

andyor_1-1675486279344.png

 

 

If I add on some extra text to the column header field it just makes the columns go longer to accomodate the new text

 

andyor_2-1675486330266.png

 

But what I want is for the column to go wider, not longer. So the text wraps around and goes over 2 lines consinstently across each column. 

 

andyor_0-1675486228610.png

 

The only way it looks like I can curently do this is to manually move each column header into place, with the 'wrap text' option enabled. But this is not feasible as I have maybe 200 column headers, which grows by 1 dynamically each week. 

 

1 ACCEPTED SOLUTION
selimovd
Super User
Super User

Hey @andyor ,

 

as you said by default you have to do that manually.

However there are a few hacks. I think the best approach is the following:

The ultimate hack to set column widths in a matrix | Esbrina (esbrina-ba.com)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍

Best regards
Denis

Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic

View solution in original post

2 REPLIES 2
selimovd
Super User
Super User

Hey @andyor ,

 

as you said by default you have to do that manually.

However there are a few hacks. I think the best approach is the following:

The ultimate hack to set column widths in a matrix | Esbrina (esbrina-ba.com)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍

Best regards
Denis

Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic

Hi @selimovd this link seems great in theory but it doesn't explain how to do the steps it shows. 

 

I tried adding the below as a new column but there isn't a column width table or column in my dataset, so that can't work. The solution also talks about calculation group column, alternate values etc .

 

When I download the pbix file there are 2 extra tables - Column Width and Spacing. They both have an 'Ordinal' attached and there's no mention of this in the solution. The other table is 'Sales', and there are no new columns or measures here either. 

 

Where are we entering code like the below? 

 

5 (format string expression) =
VAR currentValue =
    SELECTEDMEASURE ()
VAR currentLength =
    LEN ( CONVERT ( currentValue, STRING ) )
VAR selectedLength =
    CONVERT (
        SELECTEDVALUE ( 'Column Width'[Column Width], currentLength ),
        INTEGER
    )
VAR extraSpaces =
    IF ( selectedLength > currentLength, selectedLength - currentLength, 0 )
VAR prefix =
    REPT ( UNICHAR ( 0160 ), extraSpaces )
RETURN
    """" & prefix & """"
        & SELECTEDMEASUREFORMATSTRING ()

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.