Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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:
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?
Solved! Go to 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 KUDOS. Feel free to reach out if you need further assistance.
Thanks and Regards
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.
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 KUDOS. Feel free to reach out if you need further assistance.
Thanks and Regards
Thanks, that worked and is exactly what I needed!
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.
Proud to be a Super User! | |
Thanks for the links! I'll check them out and give them a try 🙂
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!