Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Leverage your QlikView investment to modernize BI – see how! Join Group
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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
Highlighted
Partner
Partner

Re: Dynamically changing Dimension values

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

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

 

and the variable you dynamically define

 Field ={'x'}

 

Highlighted
Contributor III
Contributor III

Re: Dynamically changing Dimension values

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?

Highlighted
Partner
Partner

Re: Dynamically changing Dimension values

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)
Highlighted
Contributor III
Contributor III

Re: Dynamically changing Dimension values

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

Re: Dynamically changing Dimension values

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

Re: Dynamically changing Dimension values

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
Highlighted
Contributor III
Contributor III

Re: Dynamically changing Dimension values

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.