Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Fragmenting long formula in expression

Hello,

I’m implementing forward price calculation, which results in extremely long formula. To make a chart I can put it all into the extension. But this will be hard to modify and maintain it the further. Do you know if some elegant way exists to break this expression? How such formula can be split into components, but still be used dynamically?

Thanks a lot in advance!

/Stanislav

formula.png

1 Solution

Accepted Solutions
Gysbert_Wassenaar

You need to use SET here. LET will evaluate the expression which is not what you want in the script. So SET c = a+b;


talk is cheap, supply exceeds demand

View solution in original post

5 Replies
Gysbert_Wassenaar

You could put parts of the expression in variables and then use the variables in your expression. A simple example:

variable vPart1: sum(Sales)

variable vPart2: sum(total Sales)

expression: $(vPart1) / $(vPart2)


talk is cheap, supply exceeds demand
MEllinghausen
Creator III
Creator III

Hallo,

you can put the formula into one variable or split the formula and create several of variables.

Marcus

Not applicable
Author

Hi,

You can store your expresion in a variable(s).

When you create the expression don't type the "=".

After, you can call this variable like $(VariableName) in the chart expressions.

Ej:

($(A) + $(B)) / $(C)

Regards,

Ricardo

Not applicable
Author

Gysbert, Marcus, Ricardo, thanks a lot for your the responses! But I have problem’s figuring out how it can be defined (sorry for newbies/dummy questions).

Let say I loaded a table with two number columns: 'a' and 'b'. Now I want to create formula as: c = a+b.

I guess I need to define in the script

LET c = a+b;

and then use an expression $(c) in the chart. But it doesn't work that way...

Gysbert_Wassenaar

You need to use SET here. LET will evaluate the expression which is not what you want in the script. So SET c = a+b;


talk is cheap, supply exceeds demand