Forum Discussion
Error with y-axis max scale adjustment
- 1 year ago
Hi pminnov ,
Power BI’s conditional formatting for axis scales (like y-axis max) expects a scalar value from a measure. Even if your DAX produces a valid numeric scalar (like 19.8), if it depends on a table or a variable that becomes empty in filtered contexts, Power BI may fail silently and ignore the formatting, falling back to auto-scaling the axis.
Hope this helps!
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. - 9 months ago
Update: I ran into the same issue with the same type of visual again but with slightly different data. I used co-pilot, uploaded some of my data and it eventually explained that Power BI’s Axis Auto-Scaling is “nice number” based. Power BI does not always set the axis max to the highest data value. Instead, it chooses a “nice” round number that is just above or near the highest value, but sometimes it can be slightly below if the highest value is close to a round number. The charting engine tries to optimize for readability and gridline spacing. If the highest value is only slightly above a round number, Power BI may still use the lower round number for the axis max. If the highest value is above the axis max, Power BI will still plot the point, but it will appear at the top edge of the chart, sometimes even slightly above the last gridline. This can make the chart misleading, as it looks like the axis max is lower than the highest data point. If Power BI’s auto-scaling logic decides that a value is “good enough” for the axis max, it will ignore your conditional formatting unless the returned max value in your measure (the max value in the visual multiplied by some number to return the value to be used as the y-axis max value) is significantly higher than the auto-scale value or unless the chart type/visualization engine allows for more flexibility. The solution is to either use a higher multiplier in the DAX formula (the value that is multiplied against the MAX value) or use a DAX formula such as:
Y-axis Max Measure =
VAR MaxValue = [Your Max Calculation]
VAR NextRound =
CEILING ( MaxValue, 1 )
RETURN
NextRoundThere are trade-offs to both approaches but this does fix the problem I posted about.
Hi pminnov ,
Power BI’s conditional formatting for axis scales (like y-axis max) expects a scalar value from a measure. Even if your DAX produces a valid numeric scalar (like 19.8), if it depends on a table or a variable that becomes empty in filtered contexts, Power BI may fail silently and ignore the formatting, falling back to auto-scaling the axis.
Hope this helps!
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Update: I ran into the same issue with the same type of visual again but with slightly different data. I used co-pilot, uploaded some of my data and it eventually explained that Power BI’s Axis Auto-Scaling is “nice number” based. Power BI does not always set the axis max to the highest data value. Instead, it chooses a “nice” round number that is just above or near the highest value, but sometimes it can be slightly below if the highest value is close to a round number. The charting engine tries to optimize for readability and gridline spacing. If the highest value is only slightly above a round number, Power BI may still use the lower round number for the axis max. If the highest value is above the axis max, Power BI will still plot the point, but it will appear at the top edge of the chart, sometimes even slightly above the last gridline. This can make the chart misleading, as it looks like the axis max is lower than the highest data point. If Power BI’s auto-scaling logic decides that a value is “good enough” for the axis max, it will ignore your conditional formatting unless the returned max value in your measure (the max value in the visual multiplied by some number to return the value to be used as the y-axis max value) is significantly higher than the auto-scale value or unless the chart type/visualization engine allows for more flexibility. The solution is to either use a higher multiplier in the DAX formula (the value that is multiplied against the MAX value) or use a DAX formula such as:
Y-axis Max Measure =
VAR MaxValue = [Your Max Calculation]
VAR NextRound =
CEILING ( MaxValue, 1 )
RETURN
NextRound
There are trade-offs to both approaches but this does fix the problem I posted about.