Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
WE ARE LISTENING! New Navigation for Qlik Community, Sept. 26: TELL ME MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
yamananalytic
Creator II
Creator II

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
Partner - Champion II
Partner - Champion II

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
Partner - Champion II
Partner - Champion II

Have u tried to surround the table by quotes:

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

yamananalytic
Creator II
Creator II
Author

Still Null !?

sunny_talwar

How about this

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

yamananalytic
Creator II
Creator II
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?

yamananalytic
Creator II
Creator II
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
Partner - Champion II
Partner - Champion II

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

yamananalytic
Creator II
Creator II
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.