I have a bar chart with one dimension and one expression (say v1). This expression is complex and time consuming.
I want to sort the chart by asc or desc based on some condition. I was going to multiply the yvalue by -1/1 for this in the sort expression. But I dont want to write the complex expression again in sort expression and calculate it twice. This is giving performance issue. Instead I want to refer it by name (-1*v1) in sort expression.
I see one expression can be referred in another by name. Wondering if it can be in sort expression.
Dont want to have two charts with different sort orders.
One thing you can do is copy the expression in variable and then call variable in expression and also for sorting expression.
Yes, as Kaushik mentioned u have to declare that expresion in Sory by expression and then use ASC / DESC as client needs.
Thanks but I don't think this answers my question.
If you mean to solve repeating the expression text at two places then that is not my problem.
If you mean to calculate the variable value once and use it in multiple places, then it is not a calculate once and use it many time situation like a text box but a chart where the expression value by itself changes based on the dimension values. In fact my expression is in a variable only. It still calculates multiple times if used in chart expression and in sort expression, as intended.
In any which way it is going to be calculated twice. To optimize the performance you should look to optimize the calculations used in your expression.
If one expression is referred by name in another expression then it wont be calculated twice. The question is if it can be done in sort expression. I guess the answer is no. Thanks for your reply though.