Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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)
;
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;
Hi.
IterNo() is applicable for while statements.
For autogenerate use RowNo().
Go for RecNo() or Autohash
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!
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;
Well,
I would consider it a ‘non-documented-feature.. ’, but nevertheless, your workaround work just fine.
Thanks for your help!
Regards,
Shaul