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: 
Not applicable

Just an information about "Alias"

Hello,

I have juste a little question about the function ALIAS.

I noticed that ALIAS function works with an XLS loads like this :

Alias Name as NewName;

TableName:

LOAD *

FROM

(ooxml, embedded labels, table is Feuil1);

But, this same code doesn't work with a QVD file. QlikView generates a new table named $Orphan_NewName...

Could you explain to me?

Alias Name as NewName;

TableName:

LOAD *

FROM

(qvd);

Thanx,

10 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

Alias renames the column names in the script.  Let's see it with an example

Alias A as Name, B as Number, C as Date;

Test:

LOAD

*

INLINE [

A,B,C

1,2,3 ];

Test2:

LOAD

*

INLINE [

A,Temp1, Temp2

1,2,3 ];

When you execute the above script the columns are renamed  A as Name, B as Number, C as Date. 

In table Test2 also this renaming happens. 

Hope this helps you.

Regards,

Jagan.

pokassov
Specialist
Specialist

Hi! It sounds ridiculous, but if you add line

     "where 1=1"

after

     "load * from .... (qvd)"

it will be ok.

I've tested this example:

ALIAS F2 as FAFA;

t1:

LOAD *

FROM

(qvd)

where 1=1 ;

And thanks community for answer:

Orphan tables created by Alias statement

Not applicable
Author

Oh my God !!!!!

I think that is not a good way...

pokassov
Specialist
Specialist

Yes. We lose velocity.

I think you can use this way:

1. Add 2 columns to excel

FieldFrom

FieldTo

2. load first line from qvd. It's quickly;

3. using something like this

for i=1 to NoOfFields('t1')

  LET vFieldNAME=FieldName(i,'t1');

  If vFieldNAME=FieldFrom then

Let vFieldNAME=FieldTo;

end if;

t2:

LOAD

  '$(vFieldNAME)' as field_name

AutoGenerate (1);

NEXT i;

t3:

LOAD

  Concat(field_name,',') as fields

Resident

  t2;

So you get the fields list despite "*"

4. exctract fields value into variable "vFields" and build vLoad

let vLoad='load '&vFields&' from '&<Your qvd file>

So you can save velocity and set script dinamic.

Sergey

jagan
Luminary Alumni
Luminary Alumni

Hi,

We can also rename the fields using mapping table.  Check below link

https://community.qlik.com/blogs/qlikviewdesignblog/2012/09/25/how-to-rename-fields#comment-23449

Regards,

Jagan.

Not applicable
Author

I've tried with mapping table, but my problem is that I want rename a field to creat a link betwen two tables.

So, The New name already exists in another table and it doesn't works...

Do you have an idea?

pokassov
Specialist
Specialist

Hi, Beaulieu!

Look at my suggestion above. You can avoid "name already exists" situation.

Not applicable
Author

Could you explain me more about this point : 2. load first line from qvd. It's quickly; ?

Thanx

pokassov
Specialist
Specialist

I've created example to explain my approach.

First 2 tables are for generate test files.

Can you check it?