Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Why does renaming not work?

HI

"A as B" that should be the easy way to rename right???

So why does this not work:

LOAD Name1,

     Name2,

     Name3,

     Name4 as NameA,

     if(NameA <50, '<50', if(Name A <100, '<100', if(Name A <5000, '<5000'))) .... as Example,

     Name5,

     Name 6,

     ....

....

Without "...as NameA", that is just using Name4 works fine. 

1 Solution

Accepted Solutions
Not applicable
Author

Hi,

You LOAD the field Name4 as NameA but the loaded field is still Name4 until you complete the LOAD statement.

So in the next statement you can't refer to NameA because the LOAD statement is not completed.

Only after the completion of the LOAD sratement you can refer to NameA.

What you may do is Name4 as NaneA and in the next line Name4 as NameB etc

Your if statement can only be used with the field Name4 (or any other field you are loading).

Regards,

Gerrit

View solution in original post

23 Replies
rustyfishbones
Master II
Master II

Check the If Statement

You have spaces after the named field like Name A it should be NameA

2013-11-10_1807.png

Change it and let me know if it helps

Regards

Al

Not applicable
Author

Hi,

You LOAD the field Name4 as NameA but the loaded field is still Name4 until you complete the LOAD statement.

So in the next statement you can't refer to NameA because the LOAD statement is not completed.

Only after the completion of the LOAD sratement you can refer to NameA.

What you may do is Name4 as NaneA and in the next line Name4 as NameB etc

Your if statement can only be used with the field Name4 (or any other field you are loading).

Regards,

Gerrit

Not applicable
Author

Nice spotted , but still it does not work. I just use these as examples as I use Danish words in my real script.    

rustyfishbones
Master II
Master II

Can you share an example Mikael?

rustyfishbones
Master II
Master II

How did I miss that one!

Not applicable
Author

Thx, that answered my Q why it did not work.

So what is the solution?  I tried to make a separate Load before this one:

LOAD Name4 as NameA

...

LOAD Name1,

     Name2,

     Name3,

     NameA,

     if(NameA <50, '<50', if(Name A <100, '<100', if(Name A <5000, '<5000'))) .... as Example,

     Name5,

     Name 6,

     ....

....

No luck with that, lol.

israrkhan
Specialist II
Specialist II

Hi Mikael,

as Gerrit explian that Rename fields are not available untill load does not complete,

logically query executed like below:

From>> Where>> GroupBy >> Having clause >> Select>> OrderBy,

it mean you can use your rename fields in Orderby Clause, but not before that,,, so you should use real fields name not the renamed ones. like below:

LOAD Name1,

     Name2,

     Name3,

     Name4 as NameA,

     if(Name4 <50, '<50', if(Name4 <100, '<100', if(Name4 <5000, '<5000'))) .... as Example,

     Name5,

     Name 6,

..... and you can use field like Name A, either it should be Name_A or enclosed in brackets like [Name A]

Hope it helps..

Not applicable
Author

Sorry I cannot share the specific data, if that is what you mean.

rustyfishbones
Master II
Master II

ok no problem, you have it sorted now so it's cool