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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Help regarding creating variable in qliksense.

hi all ,

i have developed dynamic measure selection in qlikview by making all my metrics into a line load then i called all the metrics as a feild of metrics . then in a bar chart i called the selection of that feild by getfeildseelction,,, and it was working fine now i wanna create the same in qliksense can some one help me with that pls.

12 Replies
hic
Former Employee
Former Employee

You can do exactly the same in Qlik Sense. The variables are however not exposed in the UI, so you cannot define them there. But you can define them in the script.

You have a field called "Metric". Then you could define the a variable "vMetric" the following way:

   Let vMetric = '=Only(Metric)' ;

and subsequently use this in your expressions.

HIC

Anonymous
Not applicable
Author

i am trying it the same way , but i am not getting it

i took my field Metrics into a filter , then i edited the expression in bar graph as sum($(vMetrics))

but i am not getting it .

hic
Former Employee
Former Employee

And how have you defined the variable vMetrics?

HIC

Anonymous
Not applicable
Author

let vMetrics = '=Getfieldselections(Metrics)';

then in measure the expression is

sum($(vMetrics))

hic
Former Employee
Former Employee

It works fine when I use it with the formulas you suggest...

Image1.png

The numbers (30+38+0=68) are indeed the Sum(Qty) for the different countries.


HIC

Anonymous
Not applicable
Author

please find the snapshot of the edit script  is there any thing wrong in this?Capture.PNG

hic
Former Employee
Former Employee

Looks OK. But if you have spaces in the metrics, you need to use quotes when you use the variable:

   sum("$(vMetrics)")

HIC

Anonymous
Not applicable
Author

tried this also , but i see no associations

hic
Former Employee
Former Employee

Then you need to post some data. It works in my test data, also with spaces:

Image3.png

HIC