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: 
SatyaPaleti
Creator III
Creator III

How to ignore cannot open file error qliksense

Hi Everyone,

We are loading application with two tables Table A & Table B. if Table A missing, the application will pop up an error like "cannot open file"  but this should not happen. Application should ignore this error and continue it's execution

I am using below code to avoid this error but it's not working

set ErrorMode = 0;
Query_Target:
LOAD
Consignment_No,
Track_No,
Packet_Id,
Barcode_Status,
Destination,
Shipment
FROM [lib://AttachedFiles/Query Target.xlsx]
(ooxml, embedded labels, table is Sheet1);

set ErrorMode = 1;

Query_Status:
LOAD
statuscode,
description,
resolution
FROM [lib://AttachedFiles/Query Status.xlsx]
(ooxml, embedded labels, table is Sheet1);

 

Currently Query Target Table is not available but application should not through an error I am using Set ErrorMode but it's not working below error is coming

MicrosoftTeams-image.png

 

is there any alternate way to achieve my requirement. Could some one help me on this

Thanks,

Satya

 

 

 

Labels (1)
1 Solution

Accepted Solutions
Andrea_Spinetti
Former Employee
Former Employee

Hey @SatyaPaleti , you could try something like this:

 

if IsNull(filesize('[lib://AttachedFiles/Query Target.xlsx]')) = -1 then

 LET vExistFile = 0;
else   
 LET vExistFile = 1;
endif;

if '$(ExistFile)' then

Query_Target:
LOAD
Consignment_No,
Track_No,
Packet_Id,
Barcode_Status,
Destination,
Shipment
FROM [lib://AttachedFiles/Query Target.xlsx]
(ooxml, embedded labels, table is Sheet1);

endif

Query_Status:
LOAD
statuscode,
description,
resolution
FROM [lib://AttachedFiles/Query Status.xlsx]
(ooxml, embedded labels, table is Sheet1);

If the issue is solved please mark the answer with Accept as Solution.

View solution in original post

3 Replies
Andrea_Spinetti
Former Employee
Former Employee

Hey @SatyaPaleti , you could try something like this:

 

if IsNull(filesize('[lib://AttachedFiles/Query Target.xlsx]')) = -1 then

 LET vExistFile = 0;
else   
 LET vExistFile = 1;
endif;

if '$(ExistFile)' then

Query_Target:
LOAD
Consignment_No,
Track_No,
Packet_Id,
Barcode_Status,
Destination,
Shipment
FROM [lib://AttachedFiles/Query Target.xlsx]
(ooxml, embedded labels, table is Sheet1);

endif

Query_Status:
LOAD
statuscode,
description,
resolution
FROM [lib://AttachedFiles/Query Status.xlsx]
(ooxml, embedded labels, table is Sheet1);

If the issue is solved please mark the answer with Accept as Solution.
SatyaPaleti
Creator III
Creator III
Author

Hi @Andrea_Spinetti 

Thank you so much for your response and it's working as expected. but it's working when we are loading excel data but when we are loading data from db still it showing null

if IsNull(filesize('[lib://AttachedFiles/Query Target.xlsx]')) = -1  this point working for excel

if IsNull(filesize('"air_prod"."air_edc_dv"')) =-1 still it showing null even data is available

is there any alternate way to make it not null?

Thanks,

Satya

Andrea_Spinetti
Former Employee
Former Employee

Hello @SatyaPaleti, the filesize() function returns an integer containing the size in bytes of the file filename or, if no filename is specified, of the table file currently being read. You are getting null probably because the argument you are passing to the function is not a file name. Maybe this thread could help you.

If the issue is solved please mark the answer with Accept as Solution.