Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Use FieldName((IterNo(), ..) in a Load statement

Hi, what do I do wrong? ...

Thanks,

Shaul

unQUALIFY *;

Facts:

LOAD * INLINE [

    FactA, FactB, FactC

    100, 200, 300

];

Set vTableName = 'Facts';

Let vNoOfFields = NoOfFields(vTableName);

trace vTableName= $(vTableName);

trace vNoOfFields $(vNoOfFields);

Let vFieldName1 = FieldName(1, vTableName);

Let vFieldName2 = FieldName(2, vTableName);

Let vFieldName3 = FieldName(3, vTableName);

Trace vFieldName1 = $(vFieldName1);

Trace vFieldName2 = $(vFieldName2);

Trace vFieldName3 = $(vFieldName3);

nullasvalue *;

Set NullValue = 'FieldName() Failed!!' ;

QUALIFY *;

m: 

LOAD 

  Iterno() As ROW_ID

  ,FieldName((Iterno()), '$(vTableName)') as [FieldName]

  ,FieldName(1, '$(vTableName)') as [FieldName_test1]

  ,FieldName(2, '$(vTableName)') as [FieldName_test2]

  ,FieldName(3, '$(vTableName)') as [FieldName_test3]

AutoGenerate 1 While IterNo() <= $(vNoOfFields)

Capture2.PNG.png

Capture1.PNG.png

1 Solution

Accepted Solutions
whiteline
Master II
Master II

Ah... Sorry.

Strange, seems like IterNo()/RowNo() is not actually a regular function.

Ok, the only way I've found is manual loop:

//QUALIFY *;

for i=1 to $(vNoOfFields)

m:

LOAD

  $(i) As ROW_ID

  ,FieldName($(i), '$(vTableName)') as [FieldName]

  ,FieldName(1, '$(vTableName)') as [FieldName_test1]

  ,FieldName(2, '$(vTableName)') as [FieldName_test2]

  ,FieldName(3, '$(vTableName)') as [FieldName_test3]

  AutoGenerate 1;

next i;

View solution in original post

5 Replies
whiteline
Master II
Master II

Hi.

IterNo() is applicable for while statements.

For autogenerate use RowNo().

sujeetsingh
Master III
Master III

Go for RecNo() or Autohash

Not applicable
Author

Hi,

Indeed I use the while statement (see provided code snippet above). When referencing the IterNo() as a column, it populates correctly, yet when being used inside the the FieldName() function it cases it to fail.  it seems as the same behavior occurs when using RecNo(), RowNo(), and AutoNumberHash().

Could you please provide code snippet that actually work?

Thanks!

whiteline
Master II
Master II

Ah... Sorry.

Strange, seems like IterNo()/RowNo() is not actually a regular function.

Ok, the only way I've found is manual loop:

//QUALIFY *;

for i=1 to $(vNoOfFields)

m:

LOAD

  $(i) As ROW_ID

  ,FieldName($(i), '$(vTableName)') as [FieldName]

  ,FieldName(1, '$(vTableName)') as [FieldName_test1]

  ,FieldName(2, '$(vTableName)') as [FieldName_test2]

  ,FieldName(3, '$(vTableName)') as [FieldName_test3]

  AutoGenerate 1;

next i;

Not applicable
Author

Well,

I would consider it a ‘non-documented-feature.. ’, but nevertheless, your workaround work just fine.

Thanks for your help!

Regards,

Shaul