Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
LINKEDIN LIVE: Democratizing data to enhance customer-centricity. JULY 29TH REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
johngouws
Partner
Partner

Change variable if files don't exist

Good morning, 
I am looking for a way to change a path variable. If the files do not exist in the RAW folder, load them from another folder. 

It is important to use the number of files instead of EXISTS because some projects will have more files than others. 

// This section counts the QVD's - In this case I get 3
Set vRoot = 'C:\RAW\Sense_QVDs';

Sub NoOfFiles(myPath, myNoOfFiles)
// Count the number of files, meeting creteria, in a path
Let tNoOfFiles = 0;
For Each File In Filelist ('$(myPath)')
// Count +1 for each file in the path
Let tNoOfFiles = tNoOfFiles + 1;
Next
Let $(myNoOfFiles) = tNoOfFiles; // Declare the variable and set the value
Set tNoOfFiles=; // Undeclare
End Sub

// Save the NoOfFiles in variable "vNoOfFiles"
Call NoOfFiles('$(vRoot)\Min_v0_*.qvd', 'vNoOfFiles')

// At this stage I have 3 QVD's


IF $(NoOfFiles) = 3 THEN

SET vRAW_QVDFolder = [C:\RAW\Sense_QVDs];
SET vWorking_QVDFolder = [C:\Projects\ProductionData];

ELSE

SET vRAW_QVDFolder = [C:\Projects\ProductionData];
SET vWorking_QVDFolder = [C:\RAW\Sense_QVDs];

ENDIF

.......

Thank you very much for you assistance. 

 

0 Replies