Skip to main content
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

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

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

Set vTempDate = 2013 ;

...

ASD01 as $(vTempDate)01,

ASD02 as $(vTempDate)02,

JonnyPoole
Employee
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