Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
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
MayilVahanan

Hi

Try like this

Load * from tablename where 1=1;

Hope that helps

Gives only field name

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

Hi,

You can use FieldName() function.

Ex.

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

Regards,

Janzen

Not applicable
Author

I guess you meant "WHERE 1=2".

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

Anonymous
Not applicable
Author

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

MayilVahanan

Hi Hulk,

Ya want to use  where 1= 2 condition..

Load * from tablename where 1=2;

Wrongly typed..Thnx

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

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

Anonymous
Not applicable
Author

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
Specialist II
Specialist II

Check the attached file

Not applicable
Author

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?????