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

FieldName

Hi Guys

Is it possible to get the field names from the source Table but not the data. forexample by using FileBaseName() , i get name of the File only.

ForExample:

IDName
1Rahul
2John

When i load the above table in Qlikview ,i should get one column containing the Name of the Field (i.e. ID and Name) but no data.

i only need field names. Is it possible????????

16 Replies

Re: FieldName

Hi

Try like this

Load * from tablename where 1=1;

Hope that helps

Gives only field name

Not applicable

Re: FieldName

Hi,

You can use FieldName() function.

Ex.

FieldName(1,'Table1') will retrieve the first fieldname from Table1.

Regards,

Janzen

Not applicable

Re: FieldName

I guess you meant "WHERE 1=2".

Since 1=1 will fetch all the records while 1=2 will fetch none.

vincentmecrin
New Contributor III

Re: FieldName

Hi,

Use the function NoOfFields(tablename) to get number of fields from your table.

Then use a loop For next on each field and get the name with the function fieldName(FieldNo,tablename).

Create dynamicly into the loop a table containing fields names.

Regads

Re: FieldName

Hi Hulk,

Ya want to use  where 1= 2 condition..

Load * from tablename where 1=2;

Wrongly typed..Thnx

Not applicable

Re: FieldName

Hi guys thanks For replies..... but i want that when i load the table into Qlikview then i should get a column that will give me name of all Fields in that table .......

For example

Load

________  as FieldNames

From TableName;

I do not want any fields with data

vincentmecrin
New Contributor III

Re: FieldName

Do like this:

FOR fieldNo = 1 to NoOfFields('tablename')

           let _fieldName = fieldName($(fieldNo), 'tablename');

                     

           TABLE_FIELDS:

           LOAD

                           '$(_fieldName)' as FIELD_NAME

           autogenerate 1;

       next

Before this script, you need to load the table, and then drop it if you don't want data.

Regards

sivarajs
Valued Contributor II

Re: FieldName

Check the attached file

Not applicable

Re: FieldName

Can i do it without loading the table into qlikview first??? i mean to say that directly from the source table load the field names into one column?????