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
eneri
Helper I
Helper I

Adjusting X-Axis Max with Visual Calculation for Stacked Bar Chart

I've recently learned from a youtube video that it is possible to use visual calculation to increase the range of an axis dynamically to e.g. have 1.1 x the value of the longest. Now I've tried this on a stacked bar chart, but the MAXX function uses the total of all rows for the axis (red line), not the longest individual row (pink line). 

Screenshot 2025-07-21 at 12.17.08.png

 

It would be great to be able to extend the x-Axis as it is very close to the legend:

Screenshot 2025-07-21 at 12.34.39.png

2 ACCEPTED SOLUTIONS

Thanks for the detailed reply and all the suggestions, unfortunately:

  • When used as visual calculations, they give the same result as above: selecting the total value * 1.1 not the value of the longest bar. 
  • When using ALLSELECTED() in a "normal" measure I get an error message: 
    Screenshot 2025-07-22 at 08.11.31.png

What did work is this measure (not visual calculation) - (cyan rectangle in screenshot below)

max_by_type =1.1 * MAXX([dim_column],[measure])

 

Using the same syntax as visual calculation

vc = 1.1* MAXX(ROWS,[measure]

is not working (red rectangle in screenshot below)

 

Screenshot 2025-07-22 at 08.28.54.png

View solution in original post

v-echaithra
Community Support
Community Support

Hi @eneri ,

Your DAX measure using MAXX(VALUES(dim_column), [measure]) works correctly because it calculates the maximum total per bar via row context, whereas the visual calculation MAXX(ROWS, [measure]) fails for axis scaling since it evaluates across individual segments rather than entire rows, leading to incorrect results like the total sum instead of the maximum row.

Use this DAX measure to dynamically scale your axis based on the longest individual bar:

max_by_type =1.1 * MAXX([dim_column],[measure])

Replace dim_column with the dimension that defines each bar (example: Category, Type, etc.).

Use this measure (max_by_type) as a reference to x axis, set the x-axis maximum manually or use it in layout logic.
Please provide sampple data, so we can reproduce your requirement.

Hope this helps.
Best Regards,
Chaithra E.

View solution in original post

8 REPLIES 8
v-echaithra
Community Support
Community Support

Hi @eneri ,

We would like to confirm if you've successfully resolved this issue or if you need further help. If you still have any questions or need more support, please feel free to let us know. We are more than happy to continue to help you.

Thank you for your patience and look forward to hearing from you.
Best Regards,
Chaithra E.

v-echaithra
Community Support
Community Support

Hi @eneri ,

We would like to confirm if you've successfully resolved this issue or if you need further help. If you still have any questions or need more support, please feel free to let us know. We are more than happy to continue to help you.


Thank you for your patience and look forward to hearing from you.
Best Regards,
Chaithra E.

v-echaithra
Community Support
Community Support

Hi @eneri ,

We’d like to follow up regarding the recent concern. Kindly confirm whether the issue has been resolved, or if further assistance is still required. We are available to support you and are committed to helping you reach a resolution.

Thank you for your patience and look forward to hearing from you.
Best Regards,
Chaithra E.

v-echaithra
Community Support
Community Support

Hi @eneri ,

Your DAX measure using MAXX(VALUES(dim_column), [measure]) works correctly because it calculates the maximum total per bar via row context, whereas the visual calculation MAXX(ROWS, [measure]) fails for axis scaling since it evaluates across individual segments rather than entire rows, leading to incorrect results like the total sum instead of the maximum row.

Use this DAX measure to dynamically scale your axis based on the longest individual bar:

max_by_type =1.1 * MAXX([dim_column],[measure])

Replace dim_column with the dimension that defines each bar (example: Category, Type, etc.).

Use this measure (max_by_type) as a reference to x axis, set the x-axis maximum manually or use it in layout logic.
Please provide sampple data, so we can reproduce your requirement.

Hope this helps.
Best Regards,
Chaithra E.

burakkaragoz
Community Champion
Community Champion

Hi @eneri ,

 

I see what's happening with your visual calculation. The issue is that MAXX is looking at the total values across all rows rather than finding the maximum value within individual stacked bars.

Here's how to fix this:

Solution 1: Use MAXX with the right context Instead of your current formula, try this visual calculation:

MaxBarLength = MAXX(ALLSELECTED(), [YourMeasure])

This should evaluate each row individually rather than summing everything up.

Solution 2: Create a measure first, then reference it Create a base measure that calculates your stacked values:

StackedValue = SUM([YourColumn])

Then use this in your visual calculation:

AxisMax = 1.1 * MAXX(ALLSELECTED(), [StackedValue])

Solution 3: Use SUMMARIZE for row-level calculations

MaxIndividualBar = 
1.1 * MAXX(
    SUMMARIZE(
        ALLSELECTED(),
        [dim1],
        "RowTotal", [YourMeasure]
    ),
    [RowTotal]
)

The key is making sure your calculation evaluates at the row level, not across the entire dataset. Visual calculations sometimes need explicit context to work properly with stacked visuals.

Try Solution 1 first as it's the simplest approach. You can find more details about visual calculations in the Power BI visual calculations documentation.


If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.

This response was assisted by AI for translation and formatting purposes.

Thanks for the detailed reply and all the suggestions, unfortunately:

  • When used as visual calculations, they give the same result as above: selecting the total value * 1.1 not the value of the longest bar. 
  • When using ALLSELECTED() in a "normal" measure I get an error message: 
    Screenshot 2025-07-22 at 08.11.31.png

What did work is this measure (not visual calculation) - (cyan rectangle in screenshot below)

max_by_type =1.1 * MAXX([dim_column],[measure])

 

Using the same syntax as visual calculation

vc = 1.1* MAXX(ROWS,[measure]

is not working (red rectangle in screenshot below)

 

Screenshot 2025-07-22 at 08.28.54.png

It's not really a "solution" as it's not using a visual calculation as requested in the initial post. But MS Community Support seems to be eager to mark any topic as solved ... 

amitchandak
Super User
Super User

@eneri , I think you should you it measure, not on running total 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.