Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

FieldName Function is not working

Set vListOfTables = ;

   For vTableNo = 0 to NoOfTables() // iterate throw tables

      Let vTableName = TableName($(vTableNo)) ; //get the name of the table.

      let VNo.ofFields = NoOfFields(vTableName);//get the number of fields.

      for i=0 to $(VNo.ofFields)-1                    //iterate throw fields.

          let VFieldName=FieldName(i,vTableName);  // get the name of the field. (Here i got NULL value)

Can any one help me please.

shivanandk

jvs

1 Solution

Accepted Solutions
OmarBenSalem

Maybe try as follow:

  for i=1 to $(VNo.ofFields)                 //iterate throw fields.

          let VFieldName=FieldName($(i),'$(vTableName)');

result:

Capture.PNG

while with

for i=0 to $(VNo.ofFields)-1                    //iterate throw fields.

          let VFieldName=FieldName($(i),'$(vTableName)');

you'll get Null: (and that's normal)

Capture.PNG

View solution in original post

11 Replies
OmarBenSalem

Have u tried to surround the table by quotes:

          let VFieldName=FieldName(i,'$(vTableName)');

Anonymous
Not applicable
Author

Still Null !?

sunny_talwar

How about this

let VFieldName=FieldName($(i),'$(vTableName)');

Anonymous
Not applicable
Author

Still NULL !?

sunny_talwar

Everything above it has the correct values? Did you add TRACE to check if the TableName is coming in correctly or not? Also, you are not changing the variable number so VFieldName will only have the last value from the last table... is that what you want?

Anonymous
Not applicable
Author

Yes Mr. Sunny i am tracing

The table name is correct and i know that just the last value is stored in the variable because firstly i want to be sure that the functions is working  after that i will add required statements but still i do not know why i get NULL Value instead of field name.

sunny_talwar

Can't see why it doesn't work.... may be someone else might be able to help

OmarBenSalem

Maybe try as follow:

  for i=1 to $(VNo.ofFields)                 //iterate throw fields.

          let VFieldName=FieldName($(i),'$(vTableName)');

result:

Capture.PNG

while with

for i=0 to $(VNo.ofFields)-1                    //iterate throw fields.

          let VFieldName=FieldName($(i),'$(vTableName)');

you'll get Null: (and that's normal)

Capture.PNG

Anonymous
Not applicable
Author

It is solved.

The correct answer is  :

The first index is 1 not 0 and come to know after  trying this code and it is working :

for i=1 to $(VNo.ofFields)

        let VFieldName=FieldName($(i),'$(vTableName)');

Next i

Thank you all.