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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Store a field into a variable

Hi everyone,

I'm trying to create a table with some years starting from a label field.

I have the label PRICE_2013 and with the instruction:

Right (@37,4) as starting_Year

I can get 2013 tha is the starting year of my study. Now I'd like to put this starting_Year into a variable  ($vyear) in order to make a loop and icrease automatically the value of the year like this:

//first year

LOAD

$(vyear) as Year,

...

////Second year

//LOAD

//($(vyear)+'1') as Year,

.....

....

I tried to set as variable with GetFieldSelections() but It doesn't work because It doesn't recognize the filed starting_Year, maybe because It don't see 2013 as an integer but as a string i don't know!

Maybe somebody can help!

Labels (1)
1 Solution

Accepted Solutions
Not applicable
Author

Why dont you try peek??

let vyear = peek('starting_Year');

View solution in original post

9 Replies
Michael_Tarallo
Employee
Employee

Hi Ylenia - are you using Sense or QlikView?

Mike

Regards,
Mike Tarallo
Qlik
Not applicable
Author

Qlickview

Mattias_Malré
Former Employee
Former Employee

Hi Ylenia

I've moved this question over to the QlikView part of the community.

All the best

-Mattias

I accept cookies.
miikkaqlick
Partner - Creator II
Partner - Creator II

Hi!

Something like this:

tmp:

Load * Inline [

Year

2014

];

Years:

NoConcatenate

Load * Inline [

Year

];

for i = 0 to 12

Concatenate (Years)

Load

     Year + $(i) as Year

Resident tmp;

next;

DROP Table tmp;

Br,

Miikka

Climber Finland

JonnyPoole
Former Employee
Former Employee

I think  the fieldname function would help you. The getfieldselections is only used in the UI when a user is making selections.

let vyear = right( fieldName( x, 'TableName'),4)

Not applicable
Author

Hi Miikka,

the table has to be dynamic, I don't wanna insert the year with the INLINE function because the data of the next year will start with the price of 2015.

I just want to read it from the label an put it in a variable.

Not applicable
Author

Why dont you try peek??

let vyear = peek('starting_Year');

Not applicable
Author

Thanks a lot Patrick It works perfectly as I wanted!

Not applicable
Author

youre welcome