Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Renaming field names using expression

Hi,

I have the following script:

Qualify *;

TableA:

select

CustomerID

,CustomerName

,CustomerRegion

from TableA;

TableB:

select

CustomerID

,CustomerName

,CustomerRegion

from TableB;

Unqualify *;

I load the data in and then create 2 table objects in QV. NOTE: these objects aren't linked in any way and can not be renamed in the script (this is important).

I need to:

Remove the qualified table name from all field names in the table object. Is there any way to do this in the label section without having to type each one in?

Thanks!

4 Replies
Not applicable
Author

For example changing TableA.CustomerRegion to CustomerRegion.

Anonymous
Not applicable
Author

if you want to load both the tables in the same data model, you should try concatenating the tables by simply removing Qualify *; statement. something like:

TableA:

select

CustomerID

,CustomerName

,CustomerRegion

from TableA;

TableB:

select

CustomerID

,CustomerName

,CustomerRegion

from TableB;

since the field names are the same in both the tables, Qlikview will autoconcatenate the tables. you will end up with one table (the name will still be TableA) but will have data from both the tables and your field names will remain the same without the prefix TableA. or TableB.

if for some reason, you want to keep the two tables separate, then the fields should be renamed in one table so that they are different from the names in the other table. this is what Qualify *; statement is doing.

Now, if you just want to remove TableA. prefix from the field names in the first table, simply move your Qualify *. statement after TableA load statement.

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

You cannot rename a field to a name that already exists. So if you rename TableA.CustomerRegion to CustomerRegion, then you will not be able to rename TableB.CustomerRegion to CustomerRegion, because at this time, CustomerRegion already exists. If I remember correctly, the rename will fail silently.

Not qualifying them is the best solution.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hi all,

Thanks for your posts.

Due to the design I cannot change the script at all. I need to find a way of renaming in the properties of the table itself.

Thanks.