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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sintax error

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?

1 Solution

Accepted Solutions
Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

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     

Help users find answers! Don't forget to mark a solution that worked for you!

View solution in original post

5 Replies
Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Hi,

When you call your function :

Call ScanFolder(vDir_ProvaACLCaric);

the second parameter is missing

Call ScanFolder(vDir_ProvaACLCaric, 0);

Help users find answers! Don't forget to mark a solution that worked for you!
Not applicable
Author

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

Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

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     

Help users find answers! Don't forget to mark a solution that worked for you!
jonathandienst
Partner - Champion III
Partner - Champion III

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

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Thank you very much again!