Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Independent validation for trusted, AI-ready data integration. See why IDC named Qlik a Leader: Read the Excerpt!
cancel
Showing results for 
Search instead for 
Did you mean: 
blunckc1
Creator
Creator

End if error

Hi community,

I just wrote my first If statement in the script (below) but QlikSense is telling me their is a script error.  Refer to screenshot attached.  But it loads fine.  Just annoying it says there is an error.

blunckc1_0-1610508165860.png

Any idea why?

The "CRASH" statement is just to highlight what I want the script to do, which is to crash so it doesn't reload anything and reverts to the last saved version.

//Load in the current employee view and check if it contains data, if it does not, exit script so it does not reload and produce errors
LIB CONNECT TO 'HR_SECURE (qh_blunckc)';
CurrentEmployeesCheck:
LOAD *;
SQL SELECT *
FROM DwhDataMart.hr."vw_current_EmployeeData"
Where CleanHolderFlag = 1 and not(ProfessionalStream='Contractor');
If NoOfRows('CurrentEmployeesCheck') = 0 THEN;
CRASH;
End If

Drop Table CurrentEmployeesCheck;

Labels (1)
1 Solution

Accepted Solutions
ArnadoSandoval
Specialist II
Specialist II

Hi @blunckc1 

Did you take the ending semicolon (;) as suggested? Now to raise an error in the script, the following document How to raise or throw an error in QlikView or Sense explains how to raise an error if a load condition is not fulfilled.

I tested the logic with the following code:

If NoOfRows('Sales') > 0 then
	trace No Data;
    CALL ThrowError ('Required file $(vFileName) not found on FTP');
End If

hth

Arnaldo Sandoval
A journey of a thousand miles begins with a single step.

View solution in original post

4 Replies
ArnadoSandoval
Specialist II
Specialist II

Hi @blunckc1 

You do not need the semi-colon (;) at the end of line 34, after the THEN, and you should use Exit Script instead of CRASH and I think it will be good if you read the help pages for TRACE 

Hope this helps,

Arnaldo Sandoval
A journey of a thousand miles begins with a single step.
blunckc1
Creator
Creator
Author

Hi @ArnadoSandoval ,

No change.  Exit script will update the data model with a table of 0 rows, which I want to avoid.    I need the script to fail, so it reverts to it's last saved version and doesn't reload anything.

Cheers

Carl

ArnadoSandoval
Specialist II
Specialist II

Hi @blunckc1 

Did you take the ending semicolon (;) as suggested? Now to raise an error in the script, the following document How to raise or throw an error in QlikView or Sense explains how to raise an error if a load condition is not fulfilled.

I tested the logic with the following code:

If NoOfRows('Sales') > 0 then
	trace No Data;
    CALL ThrowError ('Required file $(vFileName) not found on FTP');
End If

hth

Arnaldo Sandoval
A journey of a thousand miles begins with a single step.
blunckc1
Creator
Creator
Author

Hi @ArnadoSandoval 

Thanks for the new code mate!  That worked a treat and now no error is showing 🙂

Appreciate your time and effort!

Cheers

Carl