Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

crusader_
Valued Contributor

Table with Field List

Hi Community,

I have an interesting issue.

I have a fact table with several columns and I want to create a table which will include NAMEs of all of this fields.

I made it like this

[Main]:

LOAD

     Field1

     ,   Field2

     ,   Field3

     ,   Field4

     ,   Field5

     ,   Field6

     ,   Field7;

SQL EXEC sp_123;

T1:

LOAD 1 as Key

AUTOGENERATE 1;

Fields:

LOAD IterNo() as Key

          ,  FieldName(IterNo(),'Main') as FieldName

resident T1

While IterNo()<=NoOfFields('Main');

But it doesn't work.

The result is table with 2 fields: empty (means NULL) and (1,2,3...7)

Interesting fact that if I make a variable

LET FieldN=FieldName(4,'Main');

FieldN will be equal Field4.

Is it possible to use IterNo() inside FieldName() function?

Or suggest other approach.

Using QV10.

Thanks,

Any help will be appreciated.

Tags (1)
1 Solution

Accepted Solutions
Not applicable

Re: Table with Field List

for i=1 to NoOfFields('childs')

Fields: 

LOAD $(i) as Key 

          ,  FieldName($(i),'childs') as FieldName  AutoGenerate(1);

NEXT

This is not manual work.

You use loop.

In my case it works for table 'childs'.

I tryed it, ad have as much rows, as my table 'childs' has columns....

6 Replies
Not applicable

Re: Table with Field List

Hello,

don't you have in QV10 $Field, $Table system fields?

regards

Darek

crusader_
Valued Contributor

Re: Table with Field List

Dear Darek,

Thanks a lot for your response.

Thanks for fresh view as well .

But still, I'm interested in IterNo() inside FieldName() function. Are there any restrictions in using IterNo()?

Not applicable

Re: Table with Field List

For me it looks, like it can not resolve value from load context inside FieldName.... But I have not book knowledge in this area

Why not to use something like this:

for i=1 to NoOfFields('childs')

Fields: 

LOAD $(i) as Key 

          ,  FieldName($(i),'childs') as FieldName  AutoGenerate(1);

NEXT

crusader_
Valued Contributor

Re: Table with Field List

I've already tried to make this way.

But in the result I got a lot of different tables.

Manual concatenating does not seems to me attractive.

Not applicable

Re: Table with Field List

for i=1 to NoOfFields('childs')

Fields: 

LOAD $(i) as Key 

          ,  FieldName($(i),'childs') as FieldName  AutoGenerate(1);

NEXT

This is not manual work.

You use loop.

In my case it works for table 'childs'.

I tryed it, ad have as much rows, as my table 'childs' has columns....

crusader_
Valued Contributor

Re: Table with Field List

Oh, I forgot about QUALIFY statement above.

Yes, correct, I got the same result as you described.

Community Browser