Forum Discussion
Creating a dynamic y-axis on a clustered column chart with a legend
- 10 months ago
Hi deedoubleewe
The immediate issue appears to be that the maximum value should be determined at the granularity of the Legend & the X-Axis field combined.
Assuming the field on the X-Axis is
Table[Category], something like this should work as expected:YAxis Max = CEILING ( MAXX ( SUMMARIZECOLUMNS ( Table[Legend], Table[Category], "@Value", [Value] ), [@Value] ) + .05, 0.2 )You can debug or verify that
YAxis Maxis returning the expected value by displaying it on a separate Card visual (subject to the same filters applying to the original visual).Does something like this work for you?
You’re getting 0.60 because the measure is being evaluated in the context of each bar (i.e., one Group and one Legend at a time).
MAXX(VALUES(Table[Legend]), [Value]) only sees the current legend (and, due to the x-axis, the current group), so the max is computed from a reduced set—often only the bars in Group A.
Create the max from a context that keeps slicers but removes the visual’s axis and legend filters, then round it:
YAxis Max :=
VAR MaxAcrossVisual =
MAXX (
// respect external slicers but ignore the visual's Group & Legend
SUMMARIZE (
ALLSELECTED ( 'Table' ),
'Table'[Group],
'Table'[Legend]
),
CALCULATE ( [Value] )
)
RETURN
CEILING ( MaxAcrossVisual + 0.05, 0.2 )
Equivalent shorter form:
YAxis Max :=
VAR m =
CALCULATE (
MAXX ( ALL ( 'Table'[Group], 'Table'[Legend] ), [Value] ),
// ALL removes just the axis & legend filters; slicers on other columns persist
KEEPFILTERS ( ALLSELECTED ( 'Table' ) )
)
RETURN CEILING ( m + 0.05, 0.2 )
Bind YAxis Max to the Y-axis → Range → Max (fx).
Now the chart will find the true max across all groups and legend series in the visual (73.3% → rounded to 80%).
I hope it helps.