Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Questions about syntax from a newbie

Hi,

1. what is the correct syntax to define a variable in an expression?

Example in Javascript Style:

varFirstname = GetFieldSelections ([First name]);

alert varFirstname;


What is the "Syntax Translation" for this code?


2. How must i write it, if i want to save a special value, like this:


varYear2016 = {<Year = {"2016"}>} priceYear, salesYear


I want to combine the values in one variable. I want to use it in an expression for a select field. If i select 2016 it should take the values from two fields.


Thats a post Re: One field selection should get two different values about it.


regards,

Fritz



3 Replies
oknotsen
Master III
Master III

You can not define a variable in an expression.

If you want to "create" a variable, either use the Variable Overview (found under settings) or create and fill it in your script by using the SET or LET statement.

But the question is... What are you trying to achieve? Can you give us an example with some demo data?

May you live in interesting times!
reddy-s
Master II
Master II

Hi Fritz,

The link to the post which have provided will help you understand variables and its usage in Qlik thoroughly.

The Magic of Variables

The Little Equals Sign

Thanks,

Sangram

Anonymous
Not applicable
Author

Hi,

ok, how can i get that if 1 show salesYear where is it 2016 and if 2 show salesYear is it 2015?

$(=Pick(Match($(varYear),1,2),'salesYear=2016','salesYear=2015'))

regards,

Fritz