Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
bjagrelli
Contributor
Contributor

Loop values from a table

Hello everybody, I'm just starting on Qlik and got caught up in a little mess.
So, I use a REST connector to get IDs that I will later use in an API request.

It looks something like this:

LIB CONNECT TO 'CC_ID';

RestConnectorMasterTable:
SQL SELECT
"codigo",
"mensagem",
"erros",
"__KEY_root",
(SELECT
"Id",
"Nome",
"__FK_dados"
FROM "dados" FK "__FK_dados")
FROM JSON (wrap on) "root" PK "__KEY_root";

[dados]:
LOAD [Id]
RESIDENT RestConnectorMasterTable;

DROP TABLE RestConnectorMasterTable;

 

Then I'd like to loop each one of the values from the [dados] table as a query parameter on the following request. It has to be one by one.

//somewebsite.com/api/Id=$(vId)

So that I have on the first loop the vId = 1st value of the [Id] field from the [dados] table and so on

I tried using something like this:

 

LET nRows = Noofrows([dados])

FOR i = 1 to nRows

Let vId = peek([Id], i, [dados]);

Next

 

But I keep getting an error message from the "FOR i = 1 to nRows".  Is there another way of doing what I want? Please, would someone shed some light on this issue.
Thanks in advance

Labels (3)
1 Reply
edwin
Master II
Master II

it is interpreting nrow as a field try it with $(nRow)

also you should stay away from loops if you can find a way to use table operations.  that is IF