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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

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!

1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community 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.

vcazhengmsft_0-1649171999158.png

 

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.

vcazhengmsft_1-1649171999159.png

 

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.

vcazhengmsft_2-1649171999161.png

 

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] ) )

 

vcazhengmsft_3-1649171999162.png

 

vcazhengmsft_4-1649171999163.png

 

vcazhengmsft_5-1649171999163.png

 

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.

vcazhengmsft_6-1649171999163.png

 

vcazhengmsft_7-1649171999164.png

 

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

View solution in original post

2 REPLIES 2
v-cazheng-msft
Community Support
Community 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.

vcazhengmsft_0-1649171999158.png

 

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.

vcazhengmsft_1-1649171999159.png

 

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.

vcazhengmsft_2-1649171999161.png

 

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] ) )

 

vcazhengmsft_3-1649171999162.png

 

vcazhengmsft_4-1649171999163.png

 

vcazhengmsft_5-1649171999163.png

 

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.

vcazhengmsft_6-1649171999163.png

 

vcazhengmsft_7-1649171999164.png

 

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
Super User
Super User

@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. 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.