Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
breno_morais
Partner - Contributor III
Partner - Contributor III

How to dynamically create fields

Hello,

I need create fields dynamically using 'for'.

Obs.: Always have Subject 1

I try:

Table:

LOAD * INLINE [

    Category, Category_desc  

    1234, English

    1234, Maths

    1234, French

    2345, French

    2334, English       

];

Table1:

Load

Category as ID,

Category_desc as Subject1

Resident Table

Where Not Category = Previous(Category)

Order By Category, Category_desc;

let vRow = NoOfRows(ID);

for i = 2 to '$(vRow)'

  Left Join (Table1)

  LOAD

  Category as ID,

  Category_desc as 'Subject$(i)'

  Resident Table

  WHERE Category = Previous(Category)

  Order By Category, Category_desc;

Next

Drop Table Table;

But, something's wrong, any help?

1 Solution

Accepted Solutions
vishsaggi
Champion III
Champion III

It should not be NoOfRows(ID). NoOfRows function takes Table name not the Field name so try like

let vRow = NoOfRows('Table1');

View solution in original post

3 Replies
vishsaggi
Champion III
Champion III

It should not be NoOfRows(ID). NoOfRows function takes Table name not the Field name so try like

let vRow = NoOfRows('Table1');

breno_morais
Partner - Contributor III
Partner - Contributor III
Author

Ohhhh simple mistake

Thank You!

vishsaggi
Champion III
Champion III

NO problem.