I think something like this should work (it does at my place):
=if(GetCurrentField( Grp_YQZB ) = 'Quarter',500000,
if(GetCurrentField( Grp_YQZB ) = 'YearMonth',if(max(aggr(sum(Amount),YearMonth))>30000, 60000,30000)))
sum(Amount) is my expression to plot and I'm aggregating over YearMonth dimension and looking for the max aggregated value, then decide which static axis limit to chose.
Hope this helps,