Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

yamananalytic
Contributor 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
Esteemed Contributor

Re: FieldName Function is not working

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

11 Replies
OmarBenSalem
Esteemed Contributor

Re: FieldName Function is not working

Have u tried to surround the table by quotes:

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

yamananalytic
Contributor II

Re: FieldName Function is not working

Still Null !?

Re: FieldName Function is not working

How about this

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

yamananalytic
Contributor II

Re: FieldName Function is not working

Still NULL !?

Re: FieldName Function is not working

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

Re: FieldName Function is not working

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.

Re: FieldName Function is not working

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

OmarBenSalem
Esteemed Contributor

Re: FieldName Function is not working

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

Re: FieldName Function is not working

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.

Community Browser