Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
brunolelli87
Creator II
Creator II

For Loop - Table does not exist!

Hello guys,

I'm trying to run this code,  but sometimes I'm getting the following error message:

// Compondo o grupo das empresas
SET NomeEmpresas= 'AALR3', 'ABEV3', 'AFLT3', 'AGRO3', 'AHEB3', 'AHEB5', 'ALPA3', 'ALPA4', 'ALSO3';


For each Ticker in $(NomeEmpresas)

LOAD 
	'$(Ticker)'  as STCK,
	Holder, 
     Shares, 
     [Date Reported], 
     [% Out], 
     Value
FROM
[https://finance.yahoo.com/quote/$(Ticker).SA/holders?p=$(Ticker).SA]
(html, utf8, UserAgent is 'Mozilla/5.0', embedded labels, table is @2);

Next Ticker

 

Error message:

Table not found error

Table '@2' not found

LOAD 
	'AFLT3'  as STCK,
	Holder, 
     Shares, 
     [Date Reported], 
     [% Out], 
     Value
FROM
[https://finance.yahoo.com/quote/AFLT3.SA/holders?p=AFLT3.SA]
(html, utf8, UserAgent is 'Mozilla/5.0', embedded labels, table is ***)

 

Which is absolutely correct, once there is no Table 2 (@2) available on ...AFLT3.SA website.

 

My question is:

How can I create a code to check if the table exists or not, and in negative cases, just move to the next Ticker!

 

Thank you

 

1 Solution

Accepted Solutions
Frank_Hartmann
Master II
Master II

set ErrorMode=0;
// Compondo o grupo das empresas
SET NomeEmpresas= 'AALR3', 'ABEV3', 'AFLT3', 'AGRO3', 'AHEB3', 'AHEB5', 'ALPA3', 'ALPA4', 'ALSO3';


For each Ticker in $(NomeEmpresas)

LOAD
'$(Ticker)' as STCK,
Holder,
Shares,
[Date Reported],
[% Out],
Value
FROM
[https://finance.yahoo.com/quote/$(Ticker).SA/holders?p=$(Ticker).SA]
(html, utf8, UserAgent is 'Mozilla/5.0', embedded labels, table is @2);

Next Ticker

View solution in original post

3 Replies
Frank_Hartmann
Master II
Master II

set ErrorMode=0;
// Compondo o grupo das empresas
SET NomeEmpresas= 'AALR3', 'ABEV3', 'AFLT3', 'AGRO3', 'AHEB3', 'AHEB5', 'ALPA3', 'ALPA4', 'ALSO3';


For each Ticker in $(NomeEmpresas)

LOAD
'$(Ticker)' as STCK,
Holder,
Shares,
[Date Reported],
[% Out],
Value
FROM
[https://finance.yahoo.com/quote/$(Ticker).SA/holders?p=$(Ticker).SA]
(html, utf8, UserAgent is 'Mozilla/5.0', embedded labels, table is @2);

Next Ticker

brunolelli87
Creator II
Creator II
Author

Thank you!

Your solution really worked very well.

 

Now, considering my whole project, can I use this "Set ErrorMode=0" just for a specific part of my code, and then, set it back to 1?

 

Thank you

Frank_Hartmann
Master II
Master II

exactly!

Set ErrorMode=0;

...

YOUR CODE

...

Set ErrorMode=1;