Forum Discussion

calloni's avatar
calloni
Helper I
2 years ago
Solved

Fixed Width column based on largest Label

Hello,

 

I am trying to reproduce this easy to build Tableau Chart in Power BI but it is harder than it looks:

 

 

The closest that I got is this using the Matrix visual:

 

 

The main pain points with this solution are:

 

1 - The width of columns are not the same as it depends on the lenght of the label for each year

 

2 - The lenght of the chart itself does not adjust to the max  lenght of the visual. This creates a problem when I have many more years and creates an unecessary horizontal scroll bar.

 

Alternative options that I already tried include using a stacked bar chart (that fixed issue 2 as the bars adjusted to lenght of the visual card) and I used a fixed value 1 for the width of each year, but then no way to setup the colors based on the Grade column: here is how it looks:

 

 

Here is the sample that I used for this chart. 

 

Operation NumberYearGrade
1232014ALERT
1232015PROBLEM
1232016PROBLEM
1232017PROBLEM
1232018PROBLEM
1232019ALERT
1232020PROBLEM

 

If you have any ideas I would love to hear.

 

Thanks in advance

Rodrigo

  • Hi calloni 
    Matrix is the way ๐Ÿ™‚
    According to the columns width,
    to "freeze" them, you can apply these steps:
    1. Create a measure 

    rep = REPT("X",9)
    9 is the length of the longest string ("problem")+2
    2. grab it to the values :

    3. switch the values to rows:

    4. switch on auto size column width

    5. 4. switch off auto size column width

    6. remove rep measure

    Result :

     

    According to the responsivity of the matrix, you should plan the maximum width +/-, there are no other solutions

     

    pbix is attached

    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

2 Replies

  • Hi calloni 
    Matrix is the way ๐Ÿ™‚
    According to the columns width,
    to "freeze" them, you can apply these steps:
    1. Create a measure 

    rep = REPT("X",9)
    9 is the length of the longest string ("problem")+2
    2. grab it to the values :

    3. switch the values to rows:

    4. switch on auto size column width

    5. 4. switch off auto size column width

    6. remove rep measure

    Result :

     

    According to the responsivity of the matrix, you should plan the maximum width +/-, there are no other solutions

     

    pbix is attached

    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

  • Thanks for the trick... I hope it is scalable for years to come (what will happen when a new year that wasn't fixed is added to the table?)

     

    I guess I will have to wait and see ๐Ÿ™‚

     

    Rodrigo