Skip to main content

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2023, a live, in-person thrill ride. Save $300 before February 6: REGISTER NOW!
cancel
Showing results for 
Search instead for 
Did you mean: 
Smeenakshi23
Creator II
Creator II

Get List of filed Name in Load script

Hello 

I am using the  below script to fetch all the qvds from the folder.. I need to get list of all fields names..

I don want to use the system filed folder.

could you please suggest 

script:

for each File in filelist(vFolder& '\*.qvd')

load *,

FILENAME() AS TABLENAME

from [$(File)] (qvd)

where RecNo()=1;

next File

 

Labels (2)
1 Solution

Accepted Solutions
Kushal_Chawda

You can read the each QVD meta data for getting list of field name. You can slightly modify your loop like below

TableList:
load * inline [
Junk ];

for each File in filelist(vFolder& '\*.qvd')

concatenate(TableList)
LOAD
    "FieldName",
    filename() as TableName
FROM [$(File)]
(XmlSimple, table is [QvdTableHeader/Fields/QvdFieldHeader]);

NEXT File

drop field Junk;

View solution in original post

8 Replies
Anil_Babu_Samineni

Try this?

'$(File)' as TABLENAME

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Smeenakshi23
Creator II
Creator II
Author

Sorry there is  typo in my subject.. I need field names

jonathandienst
Partner - Champion III
Partner - Champion III

I understand you want a list of field names, but you have nor specified the form that you want them. Do you want to populate a variable, create a new field containing the field names, or some sort of output?

You can use FieldName() in script to get the fields in a table - for example:

For i = 1 To NoOfFields('Table')

    Let vField = FieldName(i, 'Table');
    TRACE Field #$(i): [$(vField)];

Next i

https://help.qlik.com/en-US/qlikview/April2019/Subsystems/Client/Content/QV_QlikView/Scripting/Table... 

 

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Smeenakshi23
Creator II
Creator II
Author

Sorry about it.. I need new field containing all field names.

jonathandienst
Partner - Champion III
Partner - Champion III

For i = 1 To NoOfFields('Table')

	Let vField = FieldName(i, 'Table');
	TRACE Field #$(i): [$(vField)];
	
	TableFields:
		LOAD $(i) as Index,
		'$(vField)' as FieldName
	AutoGenerate 1;
	
Next i
Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
marcus_sommer
MVP & Luminary
MVP & Luminary

One addition to the suggestion from Jonathan - if your files are qvd's you don't need to load (a part) of the file to loop through the loaded fields else you could loop through the meta-data of the qvd by using:

QvdNoOfFields() and QvdFieldName()

instead of

NoOfFields() and FieldName()

- Marcus

Kushal_Chawda

You can read the each QVD meta data for getting list of field name. You can slightly modify your loop like below

TableList:
load * inline [
Junk ];

for each File in filelist(vFolder& '\*.qvd')

concatenate(TableList)
LOAD
    "FieldName",
    filename() as TableName
FROM [$(File)]
(XmlSimple, table is [QvdTableHeader/Fields/QvdFieldHeader]);

NEXT File

drop field Junk;
Smeenakshi23
Creator II
Creator II
Author

thanks a lot