Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
OmarBenSalem

Can we track how many times the Application is reloaded in a day?

Hi guys ( stalwar1) ; I wanted to know is there a way to track how many times an application is reloaded in a single day?

In fact, what I'm doing is creating an application to finally store a table into a csv file like follow:

FileName-AsOfDate 2018-02-08

Normally, each day, we create one file; but if the users demand to reload the application a second and a thrid time;

I want to create 2 new files as follow:

FileName-AsOfDate 2018-02-08 V2 (V2=> 2 nd reload of the day)

FileName-AsOfDate 2018-02-08 V3 => 3 rd reload of the day)


is there a way to achieve this?

1 Solution

Accepted Solutions
sunny_talwar

May be this

LET vDayStart = Today();

If '$(vDayStart)' = If(Len(Trim('$(vDayEnd)')) = 0, 0, '$(vDayEnd)') then

LET vCounter = $(vCounter) + 1;

ELSE

LET vCounter = 1;

ENDIF;


Table:

LOAD * INLINE [

    Dim

    A

];


LET vSaveFile = Date('$(vDayStart)', 'YYYY-MM-DD')&'V'&$(vCounter);


STORE Table into 'FileName-AsOfDate $(vSaveFile).qvd' (qvd);


LET vDayEnd = Today();

View solution in original post

13 Replies
OmarBenSalem
Author

I thought about one way:

LET ErrorMode=0;

let vToday=date(today(1),'YYYY-MM-DD');

Construct our table and Name it final;

//Try to load the stored table in today's date:

t1:

LOAD

    *

FROM [lib://...FileName-asOf-$(vToday).csv]

(txt, utf8, embedded labels, delimiter is ',', msq);

if scriptError >0  //we can't find the file <=> it's the first reload of the day

then

Sleep 2000;

//store the table with today's date

Store final

FROM [lib://...FileName-asOf-$(vToday).csv]

(txt);

else

//store the table with today's date + Version2 key word

Store final

FROM [lib://...FileName-asOf-$(vToday)-Version2.csv]

(txt);

end if

LET ErrorMode=1;


ogster1974
Partner - Master II
Partner - Master II

HI Omar

Can you not use the operations monitor to get this information?

Regards

Andy

OmarBenSalem
Author

I have to track it within the script so that I can control the name of the files I'm storing

Anonymous
Not applicable

That is the approach I would use, but maybe I'd swerve it & use a qvd always appending to the same qvd but checking whether any rows exist for today to reset the counter to first load - as in like an incremental load.

OmarBenSalem
Author

Hi Bill,

to be able to handle  only 2 reloads;

I'm using this:

the idea is : try to load version1, if it does not exist, then store the table without version (version1)

else, store it with version 2 :

this works fine:

t1:

LOAD

    AsOf_Date

FROM [lib://Store Notionals/Aggregated Notionals-asOf-$(vToday).csv]

(txt, utf8, embedded labels, delimiter is ',', msq);

if scriptError >0

then

Store Not

into [lib://Store Notionals/Aggregated Notionals-asOf-$(vToday).csv]

(txt);

Store fx

into [lib://Store FxRates/Fx Rates-asOf-$(vToday).csv]

(txt);

else

Store Not

into [lib://Store Notionals/Aggregated Notionals-asOf-$(vToday)-Version2.csv]

(txt);

Store fx

into [lib://Store FxRates/Fx Rates-asOf-$(vToday)-Version2.csv]

(txt);

end if

drop table t1;



Now, I want to be able to control things till 3 versiosn (2 reloads)

the idea is:

try to load version2, if it exists; then store as version3

else

if version 2 does not exist, try to load version1,

if it does not exist, store it as version1 else (version1 exists), store the table as version 2:

t1:

LOAD

    AsOf_Date

FROM [lib://Store Notionals/Aggregated Notionals-asOf-$(vToday)-Version2.csv]

(txt, utf8, embedded labels, delimiter is ',', msq);

if scriptError =0

then

Store Not

into [lib://Store Notionals/Aggregated Notionals-asOf-$(vToday)-Version3.csv]

(txt);

Store fx into [lib://Store FxRates/Fx Rates-asOf-$(vToday)-Version3.csv](txt);

elseif scriptError>0 then

drop Table t1;

t1:

LOAD

    AsOf_Date

FROM [lib://Store Notionals/Aggregated Notionals-asOf-$(vToday).csv]

(txt, utf8, embedded labels, delimiter is ',', msq);

if scriptError>0 then

Store Not

into [lib://Store Notionals/Aggregated Notionals-asOf-$(vToday).csv]

(txt);

Store fx

into [lib://Store FxRates/Fx Rates-asOf-$(vToday).csv]

(txt);

else

Store Not

into [lib://Store Notionals/Aggregated Notionals-asOf-$(vToday)-Version2.csv]

(txt);

Store fx

into [lib://Store FxRates/Fx Rates-asOf-$(vToday)-Version2.csv]

(txt);

end if

drop table t1;



But, it does not work; can u see what I'm doing wrong?

OmarBenSalem
Author

When I already have 2 versions; it works fine and create a version3;

but If I don't have any version.. I have an error :

Capture.PNG

Anonymous
Not applicable

Your method of relying on csv file names will need more & more lines of code as you reload more & more times per day.

I would still go for a qvd approach based on a modified incremental load and for each day have a row for each reload version.  This will also give the bonus of having all your reload history in a single qvd that will be easy to load and visualize against.

OmarBenSalem
Author

No, the max reload time would be 3 times (on demand); the app will be loaded only one time in normal days.

And the table stored aren't even used in the application; Thus, there is no point of using incremental load.

The point is to check the integrity of the data (as they're coming from the source) without any modification.

The users have an excel file; with begin and end dates; they enter a begin and end date; and will have generated tables for each source containing all the working dates between the specified begin and end range.

then , I'll be doing some joins and transformations to use in the app; won't be using the tables as they were stored in csv..

With that being said, and knowing that we'll (AT MOST) have 3 versions per day; can u see why it's working when we already have some created versions and it creates version2 and 3; but when there is no version; I have an erro?

rittermd
Master
Master

In the latest version of QS there is a new Reload Monitor app that might give you what you want and more.