Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
chriys1337
Creator III
Creator III

fill a variable / (or new field) with a number from a calculation

Hi,

I have a (maybe beginner question) where I did not find a proper solution for.

In the front end (in a textbox) it is possible to use following formula: =sum(CL_Complete)/sum(Box_Complete), which gives me in my example a 427.

This number 427 I really would like to put in a variable in the script. Both fields are in one and the same table, but I dont have a clue how to do.

I tried it with a LET statement after loading the table, so the fields are loaded already... but it did not work

LET vL.CLperBox_calc = '=sum(CL_Complete)/sum(Box_Complete)';

LET vL.CLperBox = $(vL.CLperBox_calc);

Can anybody help me to figure out, how to get this solo number in a variable or alternatively in a solo (new) field, in a new table?

Best Regards,

Chris

3 Replies
swuehl
MVP
MVP

Maybe like this, added after you have loaded the data table in the script:

AggregatedValue:

LOAD

     Sum(CL_Complete) / Sum(Box_Complete) as NewField

RESIDENT YourAlreadyLoadedTableName;

Let vNumber = Peek('NewField',0,'AggregatedValue');

Not applicable

did u try like this ,

adding variable in variable overview  like

vt =sum(sales)/sum(amount) 

use in text object    =vt   is the condition ..

Anonymous
Not applicable

--> Alt + Ctrl + V

-->V_variable = sum(CL_Complete)/sum(Box_Complete)

-->Select a text object

--> =V_variable in the expression