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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
seattle3
New Member

Auto Resizing Height of Bar Chart in Power BI Report Builder

I have a report I'm building out in Power BI Report builder that contains multiple graphs.

 

One graph I have is a bar chart that gets filtered based on a parameter. Depending on the value of the parameter my bar chart could have 5 labels or 20. When there are a large amount of labels though the graph becomes squished like so:

seattle3_0-1742925595468.png

 

Now I could obviously manually increase the height of the graph to make this look better. But if the parameter results in the graph only showing a few labels then the height is way to big (and graphs below it will get pushed down unnecessarily). Also, this requires me to have the foresight to know how large to make the height.

 

Is there a way to auto adjust the height of my bar graph so it adjusts based on the number of labels and, for instance, a minimum height of each bar? I know a table for instance will be different heights based on number of rows, can I do something similar for a bar graph?

1 ACCEPTED SOLUTION

Hi @seattle3,

We need to pass the count of the countries once we click on a particular business unit to the dynamic width.

Since the dynamic Width is based on the filtered dataset rather than a direct parameter, you need an expression that adjusts according to the number of categories after filtering. To do this, first, count the unique categories using an expression like

=CountDistinct(Fields!Category.Value, "YourDataset")`

to determine how many labels appear after filtering. Next, set the dynamic Width by using an expression in the chart's height property, such as

=IF(CountDistinct(Fields!Category.Value, "YourDataset") * 0.5in < 10in, 
     CountDistinct(Fields!Category.Value, "YourDataset") * 0.5in, 
     10in)

,
ensuring that each label gets a minimum Width while keeping the chart within a reasonable limit. Finally, apply this dynamic Width setting to your report’s bar chart properties. This approach allows the chart's Width to adjust automatically based on the actual filtered data rather than a predefined parameter.

If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOSFeel free to reach out if you need further assistance.
Thanks and Regards

View solution in original post

6 REPLIES 6
v-nmadadi-msft
Community Support
Community Support

Hi @seattle3,
Thanks for reaching out to the Microsoft fabric community forum.

Thank you @rajendraongole1  for your valuable contribution, as per their suggestion I have successfully implemented the approach from the second referenced article, and it worked as expected. I believe it aligns with your requirements, so I recommend giving it a try.

vnmadadimsft_0-1742986788941.png

 

vnmadadimsft_1-1742986788943.png

 




If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thanks and Regards

Hi @v-nmadadi-msft ,

Thanks for testing out the solution from @rajendraongole1 's second link.

My scenario has one more level of indirection though which is tripping me up.

 

In the linked example, they are using a parameter to set how many countries to show, so DynamicHeight/Width is based of the parameter directly.

 

For me, imagine the data set you used also had a "Business Unit" column for each row. Then in your report you have a parameter to select a "Business Unit" and based on the countries that Business Unit operates in dictates which countries get shown in the graph (still based off of whatever your y-axis is, say number of sales).

 

This is where I'm getting stuck. The dynamic height is not based off a parameter, but based off the effects of filtering your data on that parameter.

 

Any ideas on how that would work?

Hi @seattle3,

We need to pass the count of the countries once we click on a particular business unit to the dynamic width.

Since the dynamic Width is based on the filtered dataset rather than a direct parameter, you need an expression that adjusts according to the number of categories after filtering. To do this, first, count the unique categories using an expression like

=CountDistinct(Fields!Category.Value, "YourDataset")`

to determine how many labels appear after filtering. Next, set the dynamic Width by using an expression in the chart's height property, such as

=IF(CountDistinct(Fields!Category.Value, "YourDataset") * 0.5in < 10in, 
     CountDistinct(Fields!Category.Value, "YourDataset") * 0.5in, 
     10in)

,
ensuring that each label gets a minimum Width while keeping the chart within a reasonable limit. Finally, apply this dynamic Width setting to your report’s bar chart properties. This approach allows the chart's Width to adjust automatically based on the actual filtered data rather than a predefined parameter.

If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOSFeel free to reach out if you need further assistance.
Thanks and Regards

Thanks, that worked and is exactly what I needed!

rajendraongole1
Super User
Super User

Hi @seattle3  - While Power BI Report Builder lacks auto-sizing like tables, using expressions for height and font size can improve visualization without excessive blank space. 

 

i found some resources related to this topic: 

please check

reporting services - set Dynamic height for SSRS stacked bar chart Report - Stack Overflow

11-Dynamic Chart Sizing – Paul Turley's SQL Server BI Blog

Hope this helps.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thanks for the links! I'll check them out and give them a try 🙂

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors