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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
hobanwashburne
Creator
Creator

Aliasing with a variable?

I'm loading a table similar to the following:

Temp01:

Crosstable(FiscalPeriodTemp, Data, 1)

LOAD

    ASDF as Key,

    ASD01 as 201301,

    ASD02 as 201302,

    ...

SQL SELECT *

FROM <ODBC Table>

where

QWER =2013;

NoConcatenate

Temp02:

LOAD

    Key,

    Data,

    Date#(FiscalPeriodTemp, 'YYYYMM') as FiscalPeriod

Resident Temp01;

Drop Table Temp01;

Currently the script functions as intended, however I need to re-alias the Fiscal Periods for each year. Is there a way to set my Alias via variable or by concatenating two fields?

i.e.

Set vTempDate = 2013

...

ASD01 as $(vTempDate) & '01',  <Doesn't Work>

or

ASD01 as QWER & '01',

1 Solution

Accepted Solutions
Colin-Albert
Partner - Champion
Partner - Champion

This should work- there are no quotes around the alias.

Set vTempDate = 2013 ;

...

ASD01 as $(vTempDate)01,

ASD02 as $(vTempDate)02,

View solution in original post

2 Replies
Colin-Albert
Partner - Champion
Partner - Champion

This should work- there are no quotes around the alias.

Set vTempDate = 2013 ;

...

ASD01 as $(vTempDate)01,

ASD02 as $(vTempDate)02,

JonnyPoole
Former Employee
Former Employee

Also, if you have spaces in there or other special characters you can safely add square brackets as in this example:

let vAlias = 'Min';

Dates:

load Distinct

  min(Date) as [$(vAlias)Date],

  max(Date) as MaxDate

from <source>

creates 'MinDate' and 'MaxDate' fields