Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Is it possible to adjust the matrix column width using DAX?

I want to create a column that if it is found to be null the width of the column will go to zero and essentially disappear. If the column is not null then it will set the column width to a certain size and fill in the column with the proper values. I am trying to use this as a way to kind of have a work around in having dynamic columns that change based off of slicer selection. Thanks!

  • Hi Anonymous ,

     

    There is no such an visibility option that supports to conditionally hide/show column in Matrix. For such needs, you may consider voting for similar ideas in Power BI Ideas.

    Links of similar ideas: https://ideas.powerbi.com/ideas/search-ideas/?q=hide%20column%20in%20matrix and https://ideas.powerbi.com/ideas/idea/?ideaid=5f080970-9ddc-4d8b-8e51-8519eef2ce60.

     

    If you want the width of the column dynamically change according to the length of its values, you need enable Auto-size column width firstly.

     

    Then currently, one option is to hide or show the values in the column by creating measures, but It depends how you create your matrix visual.

    Here are the sample data used.

     

    If use Project as Rows and status as Columns of Matrix visual, and take a Measure that do calculation for it as Values, then Matrix visual will look like the following screenshot.

     

    status_ =
    VAR count_selected =
        CALCULATE (
            COUNTBLANK ( 'Table'[status] ),
            'Table'[Project] = SELECTEDVALUE ( 'Table'[Project] )
        )
    VAR count_selected_ =
        CALCULATE (
            COUNT ( 'Table'[status] ),
            'Table'[Project] = SELECTEDVALUE ( 'Table'[Project] )
        )
    RETURN
        IF ( count_selected = count_selected_, BLANK (), MAX ( 'Table'[status] ) )

     

     

     

     

    But if you create Matrix with Project as Rows and with no field as Column, column headers are still appeared even there is no data.

     

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

     

    Best Regards,

    Community Support Team _ Caiyun

2 Replies

  • v-cazheng-msft's avatar
    v-cazheng-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    There is no such an visibility option that supports to conditionally hide/show column in Matrix. For such needs, you may consider voting for similar ideas in Power BI Ideas.

    Links of similar ideas: https://ideas.powerbi.com/ideas/search-ideas/?q=hide%20column%20in%20matrix and https://ideas.powerbi.com/ideas/idea/?ideaid=5f080970-9ddc-4d8b-8e51-8519eef2ce60.

     

    If you want the width of the column dynamically change according to the length of its values, you need enable Auto-size column width firstly.

     

    Then currently, one option is to hide or show the values in the column by creating measures, but It depends how you create your matrix visual.

    Here are the sample data used.

     

    If use Project as Rows and status as Columns of Matrix visual, and take a Measure that do calculation for it as Values, then Matrix visual will look like the following screenshot.

     

    status_ =
    VAR count_selected =
        CALCULATE (
            COUNTBLANK ( 'Table'[status] ),
            'Table'[Project] = SELECTEDVALUE ( 'Table'[Project] )
        )
    VAR count_selected_ =
        CALCULATE (
            COUNT ( 'Table'[status] ),
            'Table'[Project] = SELECTEDVALUE ( 'Table'[Project] )
        )
    RETURN
        IF ( count_selected = count_selected_, BLANK (), MAX ( 'Table'[status] ) )

     

     

     

     

    But if you create Matrix with Project as Rows and with no field as Column, column headers are still appeared even there is no data.

     

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

     

    Best Regards,

    Community Support Team _ Caiyun

  • tamerj1's avatar
    tamerj1
    Icon for Community Champion rankCommunity Champion

    Anonymous 

    Can you provide more details about your measures, data model, your matrix visual and the slicers. Maybe we can find a workaround on your workaround.