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: 
r_vdbraak
Contributor III
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
Partner - Specialist III
Partner - Specialist III

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
Contributor III
Contributor III
Author

Marcus,

Thanks so far.

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

I never used it.

qlikoqlik
Creator
Creator

HI Richard

Please try the below variables in the load script

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

Thanks and regards

Padma