Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Now Live: Qlik Sense SaaS Simplified Authoring – Analytics Creation for Everyone: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
aetingu12
Creator
Creator

Creating a new field from expression and passing value

Dear all,

I have a created a simple listbox called Views by writing this expression :

=ValueList('a','b')

Basically, I want tp pass the selection to another field to do calculations. ie if a is selected then I should be able to refer to it from another expression by writing something like:

if(view = a, sum(sales), if(view = b, cost,null))

Any guidance would be more than appreciated.

Regards,

Aksel

1 Solution

Accepted Solutions
rajivmeher
Creator
Creator

Hi aetingu12

If I understand right, you want to change a field in your calculation based on a listbox selection (correct me if I am wrong).

You can achieve it in another way. Use a inline load with selections you want to do as follows:

1.

CalcSwitch:

Load * inline

[

%ColLabel,%ColName


'a','sum(sales)'


'b','cost'

];

2. Use %ColLabel in a listbox. You will be using this to change your calculation selection.

3. In calculation use the following:

$(=%ColName)


This will change the calculation based on your selection as per what you mention in the inline table.


Regards

Rajiv.

View solution in original post

5 Replies
kaushiknsolanki

Hi,

Check this link.

Missing Manual - ValueLoop() & ValueList()

Regards,

Kaushik Solanki

Regards,
Kaushik
If reply is satisfactory, please "Like" the post.
If reply is solution, please mark as "Correct".
jonathandienst
Partner - Champion III
Partner - Champion III

Valuelist() values are not fields and so they cannot be selected.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
rajivmeher
Creator
Creator

Hi aetingu12

If I understand right, you want to change a field in your calculation based on a listbox selection (correct me if I am wrong).

You can achieve it in another way. Use a inline load with selections you want to do as follows:

1.

CalcSwitch:

Load * inline

[

%ColLabel,%ColName


'a','sum(sales)'


'b','cost'

];

2. Use %ColLabel in a listbox. You will be using this to change your calculation selection.

3. In calculation use the following:

$(=%ColName)


This will change the calculation based on your selection as per what you mention in the inline table.


Regards

Rajiv.

aetingu12
Creator
Creator
Author

Much appreciated. Exactly what I wanted to do! Thank you.

HirisH_V7
Master
Master

Hi Aksel ,

Value List can be used only to create synthetic dimension, But even if u want it to get it such way means. you can create a field from your Scriptside using match function.

=If(MATCH(Customer,'A-2-Z Solutions','Aadast'),'A',

If(MATCH(Customer,'A Superior System','A&R Partners'),'B','Other'))

Regards,

Hirish

HirisH
“Aspire to Inspire before we Expire!”