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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
dirk1955
Creator
Creator

Scripting problem

Hi, i use the following code:

Files:

LOAD

    *,

    RowNo() as RijNr

Resident FilesTemp Order By RepDate asc;

DROP Table FilesTemp;

LET vX = Peek('RijNr');

FOR x = 1 to vX

    LOAD

        X,

        RepDate,

        'F' as filter

    Resident Files Where RijNr = $(x);

LET vDate = Peek('RepDate');

LET vFile = Peek('X');

IF x = 1 then

DataPolyvalentPersoneel:

     

        LOAD num(IDF,'000000000') as IDF,

             num(IDF,'000000000') as IDFPoly,

             text(num(IDF,'000000000')) as IDFData,

//             NUM(IDF, '000000000') AS IDF,

             left(right(IDF,5),2) as Jaar_ID,

             NUM(%/100,'#,##') AS %,

             'OA' as SoortOperator,

             Kostenpl.,

             'A' AS Groep,

             'D' AS [D-post/Pool],

            % as "FTE Reporting",

            num(Inzetbaar/100,'0,00') as [$(vDate) IZ],

            date(right(SubField(FileName(),'_',1),2)&'/'&Mid(SubField(FileName(),'_',1),5,2)&'/'&Left(SubField(FileName(),'_',1),4))as DateIZ,

             if(% = Inzetbaar,'Y','N') as [%=IZ],

             [Bew uit] as [IZ Bew uit],

             date(Datum) as [IZ Datum]

        FROM

       

        (biff, embedded labels, table is [Lijst O_A$]);

ELSE

Add

    LOAD

    num(IDF,'000000000') as IDF,

             num(IDF,'000000000') as IDFPoly,

             text(num(IDF,'000000000')) as IDFData,

//             NUM(IDF, '000000000') AS IDF,

             left(right(IDF,5),2) as Jaar_ID,

             NUM(%/100,'#,##') AS %,

             'OA' as SoortOperator,

             Kostenpl.,

             'A' AS Groep,

             'D' AS [D-post/Pool],

            % as "FTE Reporting",

            num(Inzetbaar/100,'0,00') as [$(vDate) IZ],

            date(right(SubField(FileName(),'_',1),2)&'/'&Mid(SubField(FileName(),'_',1),5,2)&'/'&Left(SubField(FileName(),'_',1),4))as DateIZ,

             if(% = Inzetbaar,'Y','N') as [%=IZ],

             [Bew uit] as [IZ Bew uit],

             date(Datum) as [IZ Datum]

        FROM

       

        (biff, embedded labels, table is [Lijst O_A$]);

END If

NEXT;

The field X of the table Files: contains the list of filenames he has to process.

The first time, x = 1 hi goes through the code everything OK, hi retrieves vFile and vDate,

after the NEXT statement x becomes 2, this is OK, and then for vDate and vFile he retrieves Null for both variables???

How comes?

Thx in advance

1 Reply
fernando_tonial
Employee
Employee

hi, you can change your command FOR x for FOR Each.

See my example:

Files:

LOAD

    Concat(Chr(39)&RowNo()&Chr(39),',') as RijNr

Resident FilesTemp Order By RepDate asc;

DROP Table FilesTemp;

LET vX = Peek('RijNr');

FOR each x in vX

Best Regards.

Tonial.

Don't Worry, be Qlik.