Use a preceeding load to apply qlikview functions to the SQL output, including renames. For example:
LOAD ABC as "Cost Basis",
DEF as "Realized Gain"
SQL SELECT ABC, DEF FROM mydb.mytable
SQL also provides an "AS" clause you can use to rename, but it's more limited than using the preceeding load.
Alan, this should work
LOAD *, ABC AS XYZ;
DROP FIELD ABC;
There might be a slicker way of doing this, but if you do the above you'll effectively load ABC twice, once under an alias, and then drop the ABC field that arrived in the *. If that makes sense. Using DROP FIELDS you'll be able to drop any other duplicate fields that you have renamed. Although I always find it better to name each field you are loading in the script as you can track what's going on ... bit more time consuming to begin with but can save you plenty of tim ein the long run. - Matt
Many thanks for the above responses - it's extremely helpful.
I have run into another issue which I hope that you can help me with. As you are aware I am loading data from an SQL database. In order to make some of the information useful I have had to create a number of mapping tables which I then use as the data is loaded.
The mapping table in the below example takes a numeric list and applies a two digit code instead (which I want to seperate using the Left & Right function - detailed below).
When I try to use the 'Left' or 'Right' function on the mapped field, 'Field3' in the below example, I get an error when I run the script. The error message tells me that Field3 is not available on database.table2.
I am attempting this directly below the Applymap section, so I would have thought that this would be loaded and available.
Any help would be much appreciated!!
SQL SELECT *
Applymap('Mapping_Table1',Field2) as Field3
SQL SELECT *