Skip to main content

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Skip the ticket, Chat with Qlik Support instead for instant assistance.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Loop over each value in the field of a table

Hi guys,

I need to loop over the values in the field "DB" from table "Databases".

I am trying the code below, but it is not working.

How can I work it around?

Thanks in advance,

Aldo.

Databases:

LOAD App,

DB

FROM

..\Excel\Databases.xls

(biff, embedded labels, table is Databases$);

FOR EACH ROW In ($(DB))

FOR EACH TB In 'PART'

$(TB): SQL SELECT * FROM $(ROW).dbo.$(TB);

//Store into QVD files.

STORE $(TB) INTO $(rawDataPath)$(TB)-$(ROW)-PRI.qvd

(qvd);

//Drop tables

DROP TABLE $(TB);

NEXT

NEXT



5 Replies
Not applicable
Author

The script below seems to be working.

Aldo.

//List of Databases

Databases:

LOAD App,

DB

FROM

..\Excel\Databases.xls

(biff, embedded labels, table is Databases$)

WHERE(App = 'Priority');

LET currField = 'DB';

LET rowNo = 1;

DO WHILE rowNo < FieldValueCount('$(currField)');

LET database = FieldValue('$(currField)', $(rowNo));

FOR EACH TB In 'CUSTOMERS'

$(TB): SQL SELECT * FROM $(database).dbo.$(TB);

//Store into QVD files.

STORE $(TB) INTO $(rawDataPath)$(TB)-$(database)-PRI.qvd

(qvd);

//Drop tables

DROP TABLE $(TB);

NEXT

LET rowNo = rowNo + 1;

LOOP



Miguel_Angel_Baeyens

Hello Aldo,

You already have RowNo() and IterNo() functions which may help you with the loops.

Not applicable
Author

Thanks.

Anonymous
Not applicable
Author

Hi Aldo,

I´m searching for a code, which is similar to your Problem. Do you have a QlikView-Document, which you can send me? It is much easy to understand your code...Thanks

Not applicable
Author

[View:http://community.qlik.com/cfs-file.ashx/__key/CommunityServer.Components.UserFiles/00.00.02.89.41/Loop-over-each-value-in-a-field-of-a-table.qvw]

Hi there,

Attached a qvw with the example you need. I took the example from my model which is running ok.

I am not attaching all the Excel files you need to run the qvw, but you can easily understand the script.

I hope it helps you,

Good Luck,

Aldo.