Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
giomartini1
Contributor
Contributor

Cannot load by if condition - The error occurred here: LOOP

Hello everyone,

I'm trying to load some qvds based on specific hours and until now I don't have success. I'm already thinking it's a bug. I'm assuming this because when I copied this same script and put in a new App, it works. So I don't understand why this happens but it's annoying just think that I may need to create a new app to fix this.

We're using Qlik Sense Feb 2022 patch 6.
 
"The control statement is not correctly matched with its corresponding start statement
The error occurred here:
LOOP"
erro_qs_data_prep_ifstatement_2.jpg
 
Same script in another app:
su_qs_data_prep_ifstatement_2.jpg

  


 

Script:

IF HOUR(NOW()) > 4 AND HOUR(NOW()) < 12 THEN

Fato:
LOAD * FROM [$(vSmartTransformations)/Ebao/Fato/Fato.qvd] (qvd);

END IF

IF HOUR(NOW()) >= 12 AND HOUR(NOW()) < 19 THEN

Fato:
LOAD * FROM [$(vSmartTransformations)/SunDB/GM_SunDB_FINAL_Cocorretagem.qvd](qvd);

ELSE

T:LOAD * INLINE [
A,
1
];

END IF

EXIT SCRIPT;

Thanks,
Giovanni
Labels (1)
11 Replies
marcus_sommer

Both scripts are very similar but not identically. Before assuming any bug or a file-corruption I suggest to check the script again very carefully, for example:

  • tracing all variables as well as all conditions and their evaluation
  • each normal statement ended with ;
  • each control statement without ;
  • copying the script into an editor like Notepad++ to check each single char - I have already several cases in which there were invalid and invisible chars includes mostly caused by any copying-task

If nothing is obvious I would comment some parts and then the next and the next until you found the exact line/statement and quite often the mistake showed itself very clearly.

giomartini1
Contributor
Contributor
Author

Hi Marcus,

Thanks for the reply. I posted the wrong print, look below the exactly same script in different app and the same result. This previous one was from another attempt.

erro_qs_data_prep_ifstatement_2.jpg

I've already edit the original post with the correct prints.

Regards

marcus_sommer

Did you check the above mentioned points especially the last three? 

giomartini1
Contributor
Contributor
Author

Yes, I did. I've commented and run step by step, change to another qvd, remove the variables by include statement and tried by removing the automatically sets too.

With only the first part:

erro_qs_data_prep_ifstatement_3.jpg

 

marcus_sommer

  • make sure that the load-statement ends with a ; (it's not visible in your screenshot)
  • check all chars by copying the content to an editor
  • comment all other scripts in all other tabs or maybe move this script-part to the end of all script (there were scenarios in which script was evaluated after an exit script; and could cause an error)
giomartini1
Contributor
Contributor
Author

I've already did all these tips Marcus. Below and attached is the script, nothing else more.

IF HOUR(NOW()) > 4 AND HOUR(NOW()) < 12 THEN

Fato:
LOAD * FROM [lib://Smart BI Transformations/SunDB/GM_SunDB_FINAL_Cocorretagem.qvd](qvd);

END IF

EXIT SCRIPT; 

 

erro_qs_data_prep_ifstatement_4.jpg

marcus_sommer

This script is ok. I would now do the following testing:

  • copy this script part - and only this - into a new application
  • copy the application to have a backup and then removing all other script until this if-loop - not commenting removing everything

What happens?

giomartini1
Contributor
Contributor
Author

As I mentioned before, if I copy the same script and run it in a new app, it works. If I duplicate that app it won't work. I just modified the hour to 13 because of my time zone. See the prints below:

New app:

su_qs_data_prep_ifstatement_3.jpg

 Duplicated app 

erro_qs_data_prep_ifstatement_5.jpg

marcus_sommer

The app duplication was only meant to have a backup because all other script within the app should be deleted to exclude that it could cause any impact.

Beside that you may add another loads like:

t: load recno() as R autogenerate 1;

below your qvd-load within the if-loop and then a second time after the if-loop. Also you may try to remove the exit script; statement.

Another attempt would be to set the ERRORMODE to ignore any error, like:

set ErrorMode=0;

What happens now?