Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Setting Dynamic Field Names in Load

I'm building a new application that has lots of fields.This application will be used by different companies who like to set their own labels. So, I'd like to have a text file or excel spreadsheet that would allow an end user to create their own labels & have everything be read in correctly. Has anyone done anything like this? I've taken a stab at starting something but the FieldValue function isn't doing what I expect.

FieldLabels:
LOAD * INLINE [
LABEL_NAME, LABEL_TEXT
FIELD1_LABEL, myField1Label
FIELD2_LABEL, myField2Label
FIELD3_LABEL, myField3Label
];

FactTable:
LOAD FIELD1 as FieldValue('FIELD1_LABEL', 1),
FIELD2,
FIELD3
FROM
testdata.xls
(biff, embedded labels, table is Sheet1$);

Any ideas how I can do this?

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hello,

Use the following code according to yours:

FieldLabelsMap:MAPPING LOAD * INLINE [ LABEL_NAME, LABEL_TEXT FIELD1_LABEL, "myField1Label" FIELD2_LABEL, "myField2Label" FIELD3_LABEL, "myField3Label"]; FactTable: // Dummy data, replace for actual tableLOAD Rand() * 10 AS FIELD1_LABEL, Rand() * 5 AS FIELD2_LABEL, Rand() * 15 AS FIELD3_LABELAUTOGENERATE 200; RENAME FIELDS USING FieldLabelsMap;


Hope that helps.

View solution in original post

4 Replies
Not applicable
Author

Hi

use fieldname in the fieldvalue function....use like fieldvalue('LABEL_NAME',1)

I hope it will help you...

deepakk
Partner - Specialist III
Partner - Specialist III

hi,

If your no of Labels are very less then you can use the method applied in the attach application.

Miguel_Angel_Baeyens

Hello,

Use the following code according to yours:

FieldLabelsMap:MAPPING LOAD * INLINE [ LABEL_NAME, LABEL_TEXT FIELD1_LABEL, "myField1Label" FIELD2_LABEL, "myField2Label" FIELD3_LABEL, "myField3Label"]; FactTable: // Dummy data, replace for actual tableLOAD Rand() * 10 AS FIELD1_LABEL, Rand() * 5 AS FIELD2_LABEL, Rand() * 15 AS FIELD3_LABELAUTOGENERATE 200; RENAME FIELDS USING FieldLabelsMap;


Hope that helps.

Not applicable
Author

Hi,

I had a similar problem and used a variation of the method shown..... My requirement came from creating a Hierarchy table and I wanted a bit more flexiblity as to the number of fields I wanted to change.....

// ******************** Generate Hierachy ********************
Location_Hierarchy:
Hierarchy (LocationID,ParentLocationID,LocationName)LOAD
LocationID,
LocationName, // << Field dropped afterwards as not required
ParentLocationID
Resident Location;


// ******************** The table below is used to change the feild name (LocationName#) above to the correct lables from a previously loaded table ([LocationLevel]) containing the right lable in the 'LocationLevelName' field

Let vLocationLevelRowCount = NoOfRows('LocationLevel'); // Count the records in LocationLevel table. This will be used to rename the feild headers.

FieldLabelsMap:
Mapping LOAD
'LocationName' & RowNo() as LableName,
peek('LocationLevelName',RowNo()-1,'LocationLevel') as LableText
AutoGenerate vLocationLevelRowCount;


RENAME FIELDS USING FieldLabelsMap; // <<< This renames the failes in Location_Hierarchy