Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Live chat with experts, bring your API Integration questions. June 15th, 10 AM ET. REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
Abhishek1
Contributor III
Contributor III

Dynamically changing Dimension values

Hello Everyone,

 

I have a field with values suppose as following:

Field

x

y

z

I have used this values to create an expression where these field values are used for adding the condition like:

=sum({<Field ={'x'}>}Sales) 

and the expression label is 'x' in this case and so on for other field values used in separate equation in the chart.

Now the client is stating that the field values will change monthly. So I have to find a solution to dynamically replace the old field values with the new field values in the set analysis and in the expression label dynamically as the field values change.

 

For example: 

Suppose there are now new field values

 

Field

A

B

C

so now the set analysis should be =sum({<Field ={'A'}>}Sales) and expression label Should be A.

Can anyone please help me with this?

7 Replies
dilipranjith
Partner
Partner

Try using a variable in the set analysis e.g.

Sum( {<$(vSetVariable)>}Sales)

 

and the variable you dynamically define

 Field ={'x'}

 

Abhishek1
Contributor III
Contributor III
Author

Hi Dilip,

 

There are 5 values in the field and each is used in a different expression and label. How do I use  a variable here?

dilipranjith
Partner
Partner

Not quite sure what you mean.
assuming you are saying there are always 5 values in the field . and you have 5 different expressions and labels
Why not create the dynamic variable in script using peek function or something similar for each
e.g. vExpression1 = 'Field=' & chr(39)&Peek('Field',0,'TableName') & chr(39)

(rough code)
Abhishek1
Contributor III
Contributor III
Author

How would I use a script variable in a chart set analysis and label?
dilipranjith
Partner
Partner

Same as any other variable. Variable defined in script is accessible on UI side
vitaliichupryna
Creator III
Creator III

Hi,

In your expression Field equal A, but you also have B and C. What is the logic of this choise? It's based on user actions in UI or it's predefined in script?

If based on user actions in UI, you should create variable that will contains data from field column, something like this vFieldSelection:
=GetFieldSelection(Field)
and then your expression will be sum({<Field = {"$(vFieldSelection)"}>}Value)

Thanks,
Vitalii
Abhishek1
Contributor III
Contributor III
Author

hi,

All the expressions for A,B,C should work simultaneously and separately in the same chart. So I dont think getfield selection will work.