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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
alec1982
Specialist II
Specialist II

Variables as columns issue

hi guys,

I have a script that load multiple files and use for functions to loop over each year and then another for to loop over each month to load a set of files..

trying to add the year var and month var as columns..

the year works fine but when I add the month var as column I loose all my data and no columns show on the data model..

any idea how to fix it?

ErrorMode = 0;

FOR vYear=2014 TO 2015

for each MonthName in 'January' ,'February','March','April','May','June', 'July', 'August', 'September', 'October', 'November', 'December'

Table1:

LOAD $(vYear) as ReportYear, //work fine and shows the right value

     $(MonthName) as ReportMonth, cause errors and it cause the qvw to show no columns (Note: the errorMode=0 above)

A,

B,

C

FROM

[http://www.abc.com/~/media/Files/$(vYear)/data%20$(MonthName)%20$(vYear).xls]

(biff, embedded labels, header is 1 lines, table is [Info$]);

NEXT;

NEXT;

1 Solution

Accepted Solutions
jagan
Partner - Champion III
Partner - Champion III

Hi,

Try like this

Table1:

LOAD $(vYear) as ReportYear, //work fine and shows the right value

    '$(MonthName)' as ReportMonth,  // Need to give single quotes for strings or dates otherwise you will get error

A,

B,

C

FROM

[http://www.abc.com/~/media/Files/$(vYear)/data%20$(MonthName)%20$(vYear).xls]

(biff, embedded labels, header is 1 lines, table is [Info$]);

Regards,

Jagan.

View solution in original post

3 Replies
jagan
Partner - Champion III
Partner - Champion III

Hi,

Try like this

Table1:

LOAD $(vYear) as ReportYear, //work fine and shows the right value

    '$(MonthName)' as ReportMonth,  // Need to give single quotes for strings or dates otherwise you will get error

A,

B,

C

FROM

[http://www.abc.com/~/media/Files/$(vYear)/data%20$(MonthName)%20$(vYear).xls]

(biff, embedded labels, header is 1 lines, table is [Info$]);

Regards,

Jagan.

alec1982
Specialist II
Specialist II
Author

I just reached it at the same time you sent me your answer.. thanks so much!

tamilarasu
Champion
Champion

Hi Alec,

Just change the line as '$(MonthName)' as ReportMonth

Let me know the result.

Edit: Ignore this as Jagan Mohan also suggested the same (I was typing this and I didn't see Jagan's reply).