Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Labels for aliases for field names

Hi Guys

I've googled myself to death on the interwebs and can't find any solution.

I have a table of data that I import with field names for example

Field_abc
Field_def

Field_ghi

Field_jkl

...etc

I design the model using these original field names, however they don't mean anything much to the end user. So what I need is to assign user friendly labels that can be referenced in the headings and charts instead of these database fields.

My current approach is to load an inline table where the original field name is specified as well as an alternative user friendly field like ...

FieldNameAlternatives:

Load * inline [

_ORIGINALFIELDNAME,     _ALTERNATIVEFIELDNAME

Field_abc,                            Product
Field_def,                             Country

Field_ghi,                             Region

Field_jkl,                              Segment

...etc

];

Now I can come right with a 'RENAME FIELDS USING FIELDMAP' process ....

Buuuuuut .... it REPLACES the original field name with the alternative field name.

Normally I won't mind, but in this case (and for future dynamic design), I need to RETAIN the original field name as well as the new alternative field name.

The obvious answer is to do something like

Load

Field_abc AS Product,

Field_def AS Country,

Field_ghi AS Region,

Field_jkl AS Segment,

etc....

But this balloons the data since I'm not allowed to drop the original field. I'm pretty sure I need to use an 'applymap' function, but I'm not getting it right.

Any help or direction would be much appreciated!

Thanks

Samuel

3 Replies
settu_periasamy
Not applicable

Re: Labels for aliases for field names

May be there is a good suggestion. I would do like this..

1. Export all the Fields to the excel (use the for loop in script or $Field in front End)

2. Give the Meaningful name of the Field.

3. Load the Excel file.

4.  'RENAME FIELDS USING FIELDMAP' process - In the End of the Script

5. Maintain the Excel Sheet (Whatever field added in the Script, Need to Add in Excel also)

marcus_sommer
Not applicable

Re: Labels for aliases for field names

It isn't possible to have to two field-names for one field. If you really want to keep the origin field-names within the enduser-reports you will need to translate them then with an expression - best practice is to use a 3-tier data architecture with generator --> datamodel --> report and change the fieldnames on the scriptend from datamodel or from report the origin field-names into user-friendly ones per rename-statement.

The above mentioned expression alternatively requirred an additionally table similar like a mapping table and could look like:

only({< OriginFieldname = {'YourUsedField'}>} UserfriendlyFieldname)

maybe shortened per variable like:

var:

only({< OriginFieldname = {$1}>} UserfriendlyFieldname)

and then as expression:

$(var('YourUsedField'))

but you will need to write this probably very often and therefore it's best practice to use the userfriendly field-names already within the script.

- Marcus

Not applicable

Re: Labels for aliases for field names

Hi Settu

Thanks for the suggestion, but I managed to get that far already. The fields are ‘renamed’, which I don’t want. I want to keep the ‘new’ name as well as the ‘original’ field names.