Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
employe4_2
Contributor III
Contributor III

variable in expression

Hi experts,

I'm looking a way to use a variable in a expression of a measure from a line/combo chart.

I tried with defining a variable : vChosenField = [Field] from system fields table ==> $field

and then trying to call the variable in my line chart: $(vChosenField)

but whatever the way, it doesn't seems to be  correct.

Got an hint ?

 

thx

 

7 Replies
cmj717_GTP
Partner - Contributor III
Partner - Contributor III

 

hi

as far as I know
A variable can have one value.

For example, $(vChosenField) = [1,2,3,4,5] array is not possible.
If you do a variable = [field], the value of the variable is array.
If you choose one of the field values for the variable, variable extension will work normally.
For example, $(vChosenField) = max([field])

If it's not the answer you want,
Upload the sample qvf file for further analysis.

shiveshsingh
Master
Master

Hi

What is the expression you are trying to build? Can you share the sample app?

If you want to store all the values in Variable, use concat function.

employe4_2
Contributor III
Contributor III
Author

I'm trying to build a graphic wich adapt function of what is selected inside a filter panel( fields).

i want a variable to getFieldName([$Field]) ( field wich will be selected)

and the expression of my measure ( from a combo chart ) calling the variable to be able to switch from one graphique to an other by only selecting FieldName, fom a filter panel...

I found lot of similar question, solved for qlik view, unsolved for sense ( getFieldName existe nly in q.view)

it doesnt seems to be so ez...

 

Federico_Rizzello
Partner - Contributor III
Partner - Contributor III

Hi Employe4_2,

for your variable you can try this function:

GetFieldSelections()

which returns a string with the current selections in a field. Just be aware that in your case it seems like you should let the user select just one single field value at a time.

 

shiveshsingh
Master
Master

May be you can try getfieldselections()?

ajaykakkar93
Specialist III
Specialist III

Hi,

   Step 1: create a inline field which will be the list of fields you want to show i.e.

FieldFilter:
Load * inline [
FieldFilter
Dim1
Dim2
Dim3
];

Step 2 : Take a filter pane form the chart menu & add the dimension "FieldFilter"

Step 3 : go to the chart & add the mesure you want to add example, =sum(sales)

Step 4 : in dimension =getFieldSelection(FieldFilter)

Step 5 : go to fields section seach for "FieldFilter" & right click Field Settings it select always one selected option (this will ensure that you get only one selection for that field)

Step 6 : you can use Hide Prefix to hide that field

-----------Refer the attached Qlik Sense Application-----------

Regards,

Ajay Kakkar

 

Please mark the correct replies as Solution. Regards, ARK
Profile| GitHub|YouTube|Extension|Mashup|Qlik API|Qlik NPrinting

employe4_2
Contributor III
Contributor III
Author

 

Hi,

Thanks for  the suggestions. I did tried GetFieldSelection (FieldName) , as a variable and also simply put it in the chart expression and it kinda work .. but nah it ain't.2019-07-25_10h04_32.png

Instead giving me the values of my field , its returning the field name over and over again. Giving me no charts... How is this a thing

ajaykakkar93 : in your explanation, you specify dimension and measure, i tried something respecting your order and worked but sadly my dimension is always the time and its only my measure which change function of the user

Unixdatetime giving me my dimension, and vMeasure=GetFieldSelections([FieldName]) should giving me the  Field Name which have to be applied to Measures and giving me values ( and not field name)

I don't understand why it giving me the string : field name instead of the value of the field name ...

Any hint ?

Best regards,

Peter