Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Highlighted
r_vdbraak
New Contributor III

Use variable for fieldnames in loadscript

Hi All,

In my excel sheet if have columns with as name the year (2014,2013,2012, etc)

In the load script i have a calculated field where i use last (2014) and the previous year (2013).

Next year I need to use the columns 2015 and 2014.

I want to create a variable vLastYear and vPrevYear so I can use these in stead of hard coded data. So I only have to change the content of the 2 variables vLastYear and vPrevYear.

Load *,

     ....     

     If( ([2014] > [2013]) ,Chr(9660), Chr(9650) ) As Direction

     .....

Resident TableName;

Any suggestions ??

Thanks.

3 Replies
marcus_malinow
Valued Contributor III

Re: Use variable for fieldnames in loadscript

Hi Richard,

If I were you I'd probably load the data in using a crosstable. Then, if you use a resident load on the data, ordering by your key fields, and year, you can do your comparisons by using the peek command rather than having to refer to field names that will change year on year.

Marcus

r_vdbraak
New Contributor III

Re: Use variable for fieldnames in loadscript

Marcus,

Thanks so far.

I'm trying it and see if I can use the Peek.

I never used it.

qlikoqlik
Contributor II

Re: Use variable for fieldnames in loadscript

HI Richard

Please try the below variables in the load script

Let vThisYear = Year(Today());
Let vPreviousYear = Year(Today())-1;

Thanks and regards

Padma