Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
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. 

23 Replies
Not applicable
Author

Super, but the point is, here I have only these 3 if statements, but I want to make like perhaps 20, and the original "Name4" is a bit long, of course I can copy it or change from the original source, but it would be cool to learn a trick to handle this in the future!

Not applicable
Author

Well still I did not find the solution I hoped for.

Not applicable
Author

Hi

I am not sure if this is what you are looking for but I tried to understand your problem.

assume the follwing example:

  ='<'&text(ceil(154/50)*50) returns '<200'  (you may try it in a textbox)

If you make the function as: '<'&text(ceil(Name4/50)*50 you will always get the answer rounden 50 upward.

Don't know if it is what you are looking for, but it may save a lot of coding if it solves your problem .

Regards,

Gerrit

Not applicable
Author

Well I got the idea of if function here: Company and number aligned, and employee intervals

The case is that originally it is just a very long name to write in the code every and to read by the way, so I just hoped for a quick fix to shorten the name field, without messing with the original source.

Not applicable
Author

If it is about the renaming of the field where you want a trick for, that is simple.

1 Load the table where you can rename the field.

2 Load the table as resident and their is your renamed field that you can use as you like,

3. Drop the original table.

Regards,

Gerrit

Not applicable
Author

That's the case , and that is what I though I could do in my answer earlier "

Not applicable
Author

Myfile:

LOAD

     Name1,

     Name2,

     Name3,

     Name4 as NameA,

     Name 5

From xxxxxxxxxxx;

Newfile:

LOAD

     Name1,

     Name2,

     Name3,

     NameA,

     Name 5

Resident Myfile;

Drop table Myfile;

resident is used if data should be loaded from a previously loaded table.

Regards,

Gerrit

israrkhan
Specialist II
Specialist II

Hi Mikael,

1) first load whole data from table, and in the load just Rename your fields.

2) then load a Resident load, and in resident load you can write your if statements, and the drop the first table, you will have a new table..

if you are not aware with resident load, let me know, i will write here with example...

Not applicable
Author

Super, it seems to work 🙂

Though it did not like the "Dtop table", false statement, what does it do?

swuehl
MVP
MVP

-Mikael- wrote:

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.

I don't think you need a second load here.

Why does this not work for you:

LOAD Name1,

     Name2,

     Name3,

     Name4 as  NameA,

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

     Name5,

     Name 6,

     ....

FROM YourSource;

You can only use fields from your input table in your statements (Name1 to Name6) left from as , except when using the peek() function.

edit: Missed an answer below the one I replied to, but if you want to first rename, then calculate, you can still do a preceding load:

LOAD *,

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

LOAD Name1,

     Name2,

     Name3,

     Name4 as  NameA,

     Name5,

     Name 6,

     ....

FROM YourSource;