Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
nickjose7
Creator
Creator

How to write a conditional Load Script to toggle between extraction codes day wise?

serj_shukush141087petter-smdmukramalifranky_h79antoniotimanits.anandrjs

Hi,

I need to write a Load Script where:

1. Table A is extracted on every 1st day of month and remains till 3rd of that month.

2. On 4th day of the month, Table A is replaced by Table B and remains till the end of the month.

3. This will be an ongoing process.

4. Desired but not mandatory: An option where Table A is only replaced when Table B is available in the source folder.

Table A and Table B have same fields. Data source is Excel. The difference is in the values not the fields.

Any help would be highly appreciated.

Thanks

Nick

1 Solution

Accepted Solutions
Frank_Hartmann
Master II
Master II

Maybe something like that in loadscript:

If num(day(Today()))<4 then

TableA:

Load * From FILE_A; ELSE

TableB:

Load * From FILE_A;

end if

hope this helps

View solution in original post

4 Replies
Frank_Hartmann
Master II
Master II

Maybe something like that in loadscript:

If num(day(Today()))<4 then

TableA:

Load * From FILE_A; ELSE

TableB:

Load * From FILE_A;

end if

hope this helps

Frank_Hartmann
Master II
Master II

and if you want to check if file b exists try something like this:

LET vFile    = 'C:\Users\Admin\Desktop\Test\TableB.xlsx';

LET vFileExists = if(FileSize('$(vFile)') > 0, -1, 0);

IF $(vFileExists) THEN

IF num(day(Today()))<4 THEN

TableA:

Load * FROM

(ooxml, embedded labels, table is Tabelle1);

ELSE

TableB:

Load * FROM

(ooxml, embedded labels, table is Tabelle1);

end if

ELSE

TableA:

Load * FROM

(ooxml, embedded labels, table is Tabelle1);

its_anandrjs

In a loading, script do this way make some date variables nad then

LET vToday = Date(Today());

LET vMonthStart = MonthStart(Today());

LET vMonthEnd = MonthEnd(Today());

LET v3days = Date(vMonthStart+2);

LET v4days = Date(vMonthStart+3);

if $(vToday) <= $(v3days) then

TableA:

LOAD * Inline [

ColumnA

a

b

c ];

END If

if $(vMonthEnd) >= $(v4days) then

TableB:

LOAD * Inline [

ColumnA

a

b

c ];


END if

nickjose7
Creator
Creator
Author

Thanks Frank. This works well!!