Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
stjernvd
Partner - Creator
Partner - Creator

Load variable as table name not working

Hi,

I would like to use a variable that has a date stored in it as my table name, but I keep getting the error: Unknown Statement 01-Feb-2015.

First I load my date:

Date:

Load

Date(Timestamp#(Date,'DD-MMM-YYYY hh.mm.ss TT'),'DD-MMM-YYYY')  as Date (this works the dates look normal)

From

File;

MaxDate:

Date(Max(Date)) as MaxDate (if I only do Max(Date) as MaxDate I get the number 40125 instead of a date)

Resident

Date;

Let vMaxDate = peek('MaxDate',0,'vMaxDate'); (this also works it stores 01-Feb-2015)

Drop table Date;

Drop table MaxDate;

Set table = $(vMaxDate);

$(table):

Load

x

x

x

From

File;

and then I get the Unknown Statement: 01-Feb-2015 error message:

What am I doing wrong?

1 Solution

Accepted Solutions
Colin-Albert

Try using

     Date(Max(Date), 'DDMMYYYY') as MaxDate

to remove the dashes from the date so you use 01FEB2015 rather than 01-FEB-2015

The dash is not an acceptable character in a tablename.

I am not sure why you would want a table name that changes though.

View solution in original post

5 Replies
swuehl
MVP
MVP

Try using [...] around your variable expansion:

[$(table)]:

Load

x

x

x

From

File;

alexpanjhc
Specialist
Specialist

the dash(-) cant be used as part of table name.

sunny_talwar

Try this:

[$(table)]:

Load

x

x

x

From

File;

Colin-Albert

Try using

     Date(Max(Date), 'DDMMYYYY') as MaxDate

to remove the dashes from the date so you use 01FEB2015 rather than 01-FEB-2015

The dash is not an acceptable character in a tablename.

I am not sure why you would want a table name that changes though.

Colin-Albert

You will still need to enclose the variable in square braces or single quotes.

Either of the options below will work.

'$(table)':

Load

x

x

x

From

File;

[$(table)]:

Load

x

x

x

From

File;