You can group the expressions creating a logic island in the script that relate dimensions and expressions and using pick and match functions in the chart expression.
Although the problem is solved this way I don't know if this is the best approach to solve this kind of problem.