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

Input Box and Calculations

Hi Guys,

On one of the tables that I have on the script I got the following calculation:

Load

ID,

LL

Resident XYZ;

On the other hand I have an input box on the tab where the user can enter a value and store in variable VV.

Is there anyway to add a new column in the script to have the following

Load

ID,

LL

LL * Variable(VV) as MM

Resident XYZ.

Thxs,

Alec

1 Solution

Accepted Solutions
Anonymous
Not applicable

Interesting...  you want your field to return expression which contains variable...  Is it correct?

See this:

LOAD

ID,

LL,

If(ID<>Previous(ID), AA,                                                                 // returns number

peek('LL')  & '+($' & '(VV)/4) +' &   Peek('LL')) as MM                  // returns expression text

RESIDENT XYZ

ORDER BY ID;

You can use the value of the MM field using dollar-sign extension, like $(=MM).  Not sure about the details, give it a try.

View solution in original post

9 Replies
Anonymous
Not applicable

It will be:

Load

ID,

LL

LL * $(VV) as MM

Resident XYZ;


alec1982
Specialist II
Specialist II
Author

Hi Michael,

This will not work as the variable is 0 when we load it at first then user will enter an amount on the variable..

Mainly this new field will be dynamic based on the user input..

Thxs,

Alec

Anonymous
Not applicable

Badr,

In this case you shouldn't use it in the load script.  Use it in the front end expressions (charts and other places where you can use expressions).

LL * VV

or

LL * $(VV)

Regards,

Michael

alec1982
Specialist II
Specialist II
Author

Thank you Michael,

I didn't explain it correctly.. it is more complex

On the table I have:

Load

ID,

If(ID<>Previous(ID) and  Key - Key2=1,AA,

(peek(LL)+  (Var(VV)/4))   + Peek(LL)) as LL,

Resident XYZ;

I am wondering if i can do this inside a chart instead of on the script?

Anonymous
Not applicable

Interesting...  you want your field to return expression which contains variable...  Is it correct?

See this:

LOAD

ID,

LL,

If(ID<>Previous(ID), AA,                                                                 // returns number

peek('LL')  & '+($' & '(VV)/4) +' &   Peek('LL')) as MM                  // returns expression text

RESIDENT XYZ

ORDER BY ID;

You can use the value of the MM field using dollar-sign extension, like $(=MM).  Not sure about the details, give it a try.

alec1982
Specialist II
Specialist II
Author

Hi Michael,

This is returning the value in the field as follow   4+$(VV)/4) +4 which is great..

Now I need to present it in a chart so I used the following formula

if(VV)=0,Sum(LL),Sum($(=MM)))

But it is not working..

Let me know your thought and thxs for all your help!

Thxs,

Alec

tresesco
MVP
MVP

Could you post your sample app?

alec1982
Specialist II
Specialist II
Author

Hi,

Attached is a copy of the QVW.

the value that I am trying to show is inside the blue text box. It works only if one Quarter is selected while I needed to work for all of them so i can put it in a chart..

Thxs for your help!

Alec

alec1982
Specialist II
Specialist II
Author

Hi Any body can help on this..

Thxs so much!

Alec