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: 
northerner
Partner - Contributor III
Partner - Contributor III

FieldName not working as expected?

Hi All,

I'm trying to create a table that holds the names and position numbers of fields in a QVD. 

For example if I have a QVD with the following fields:

FIELDA, FIELDB, FIELDC

The table would be:

FIELDNAME FIELDPOSITION

FIELDA          1

FIELDB          2

FIELDC          3

The script I've written for this is:

EMPTYTABLE:
LOAD *
FROM QVDNAME (qvd)
where 1 = 0;

TABLE_FIELDS:
load IterNo() as FIELD_NUMBER,
FieldName(IterNo(), 'EMPTYTABLE') as FIELD_NAME
autogenerate 1
while IterNo() < NoOfFields('EMPTYTABLE');

This produces a table with the correct number of rows.  FIELD_NUMBER is populated correctly but FIELD_NAME is null. 

Have I missed something obvious?  I'd be greatful for any help/explanations!

1 Solution

Accepted Solutions
flipside
Partner - Specialist II
Partner - Specialist II

I wouldn't do it that way. Access the XML structure as this ...

TABLE_FIELDS:

LOAD

    Rowno() as FIELD_NUMBER,

    FieldName as FIELD_NAME

FROM [{name}.qvd] (XmlSimple, Table is [QvdTableHeader/Fields/QvdFieldHeader]);

.. really simple and quick.

flipside

EDIT: If querying multiple qvds, then the Rowno() will continue incrementing from last stored value, so RecNo() might be neaded to give you the Field_Number within the QVD.

View solution in original post

1 Reply
flipside
Partner - Specialist II
Partner - Specialist II

I wouldn't do it that way. Access the XML structure as this ...

TABLE_FIELDS:

LOAD

    Rowno() as FIELD_NUMBER,

    FieldName as FIELD_NAME

FROM [{name}.qvd] (XmlSimple, Table is [QvdTableHeader/Fields/QvdFieldHeader]);

.. really simple and quick.

flipside

EDIT: If querying multiple qvds, then the Rowno() will continue incrementing from last stored value, so RecNo() might be neaded to give you the Field_Number within the QVD.