Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to refer Chart expression by name in sort expression

Helo,

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.

Thanks,

VJ

6 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

One thing you can do is copy the expression in variable and then call variable in expression and also for sorting expression.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Anil_Babu_Samineni

Yes, as Kaushik mentioned u have to declare that expresion in Sory by expression and then use ASC / DESC as client needs.

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable
Author

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.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Vijay,

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.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Anonymous
Not applicable
Author

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.

oscar_ortiz
Partner - Specialist
Partner - Specialist

Have you tried sorting by "Y" value?

Good luck

Oscar