Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm trying to understand where i'm wrong, but I need your help.
In reference to this discussion https://community.qlik.com/thread/62449, I fixed the code according to my needs.
At first step, I wrote and tested this code, and it was ok:
Set vConcatenate = ;
Set vFileExtension = ;
Set vFoundFile = ;
Set vSubDirectory = ;
Set vPeriodo = 1;
Set vDataRif = ;
sub ScanFolder(Root)
for each vFileExtension in 'xlsx'
for each vFoundFile in filelist(Root & '\*.' & vFileExtension)
FileList:
$(vConcatenate)
LOAD *,
'$(vFoundFile)' as [FilenameWithPath],
'31/12/2014' as data_rif,
1 as id_periodo
FROM [$(vFoundFile)]
(ooxml, embedded labels, table is data);
Set vConcatenate = Concatenate;
next vFoundFile
next vFileExtension
for each vSubDirectory in DirList(Root & '\*')
call ScanFolder(vSubDirectory)
next vSubDirectory
end sub
Call ScanFolder(vDir_ProvaACLCaric);
Then, i tryied to add a nested if to the "vSubDirectory" foreach, but I really don't understand where I'm wrong:
Set vConcatenate = ;
Set vFileExtension = ;
Set vFoundFile = ;
Set vSubDirectory = ;
Set vPeriodo = 1;
Set vDataRif = ;
sub ScanFolder(Root, id_periodo)
for each vFileExtension in 'xlsx'
for each vFoundFile in filelist(Root & '\*.' & vFileExtension)
FileList:
$(vConcatenate)
LOAD *,
'$(vFoundFile)' as [FilenameWithPath],
'31/12/2014' as data_rif,
id_periodo as id_periodo
FROM [$(vFoundFile)]
(ooxml, embedded labels, table is data);
Set vConcatenate = Concatenate;
next vFoundFile
next vFileExtension
for each vSubDirectory in DirList(Root & '\*')
if(substringcount($(vSubDirectory)), 'dicembre_2014') > 0, $(vPeriodo) = 1,
if(substringcount($(vSubDirectory)), 'dicembre_2015' ) > 0, $(vPeriodo) = 2,
if(substringcount($(vSubDirectory)), 'giugno_2016' ) > 0, $(vPeriodo) = 3, 0)))
call ScanFolder(vSubDirectory, vPeriodo)
next vSubDirectory
end sub
Call ScanFolder(vDir_ProvaACLCaric);
Can someone help me, please?
IF substringcount('$(vSubDirectory)', 'dicembre_2014') > 0 THEN
SET vPeriodo = 1;
ELSEIF substringcount('$(vSubDirectory)', 'dicembre_2015') > 0 THEN
SET vPeriodo = 2;
ELSEIF substringcount('$(vSubDirectory)', 'giugno_2016' ) > 0 THEN
SET vPeriodo = 3;
ELSE
SET vPeriodo = 0;
ENDIF
Hi,
When you call your function :
Call ScanFolder(vDir_ProvaACLCaric);
the second parameter is missing
Call ScanFolder(vDir_ProvaACLCaric, 0);
Thank you very much, I fixed the error, but I I still have error in this section:
for each vSubDirectory in DirList(Root & '\*')
if(substringcount($(vSubDirectory)), 'dicembre_2014') > 0, $(vPeriodo) = 1,
if(substringcount($(vSubDirectory)), 'dicembre_2015' ) > 0, $(vPeriodo) = 2,
if(substringcount($(vSubDirectory)), 'giugno_2016' ) > 0, $(vPeriodo) = 3, 0)))
call ScanFolder(vSubDirectory, vPeriodo)
next vSubDirectory
IF substringcount('$(vSubDirectory)', 'dicembre_2014') > 0 THEN
SET vPeriodo = 1;
ELSEIF substringcount('$(vSubDirectory)', 'dicembre_2015') > 0 THEN
SET vPeriodo = 2;
ELSEIF substringcount('$(vSubDirectory)', 'giugno_2016' ) > 0 THEN
SET vPeriodo = 3;
ELSE
SET vPeriodo = 0;
ENDIF
For Each vSubDirectory in DirList(Root & '\*')
Let vPeriodo = If(SubStringCount(vSubDirectory, 'dicembre_2014') > 0, 1,
If(SubStringCount(vSubDirectory, 'dicembre_2015') > 0, 2,
If(SubStringCount(vSubDirectory, 'giugno_2016') > 0, 3, 0))
);
Call ScanFolder(vSubDirectory, vPeriodo);
next vSubDirectory
Thank you very much again!