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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Sivalingam
Contributor II
Contributor II

Run the script only on a Monday and retains the value for other days.

Hello qlikers 

I have written a script. But a small area of the script should be run on a Monday only and the generated value needs to be retained for other days.

So, for example, today is Monday and the script should run the complete script. When we have Friday, the script should use the Monday generated value on behalf of "Monday script".

How can I do that?

Thank you in advance! 

Sivalingam_1-1743519841978.png

 

Labels (5)
1 Solution

Accepted Solutions
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

It is because now() returns timestamp including date and you compare it to time which doesnt have date in it so in reality you are comparing totally different numerical values..

to understand the issue i suggest you try and put num(now()) in table object next to num(maketime(hour,minute))

time is basically decimal value and integers are days.

 

In your case try:

Frąc(Now()) >= maketime(4,20) AND Frac(Now()) <= maketime(5) THEN

Also… i am not sure about AND in control statements. Maybe you will need to nest it instead

 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.

View solution in original post

8 Replies
SRA
Partner - Creator
Partner - Creator

Hi,

You can schedule a full reload on Monday, and a partial reload on other days. 

Check https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptPrefixes... if you need more info about how you can prepare your script for partial reload. 

Regards,

SRA

Sivalingam
Contributor II
Contributor II
Author

Is there any option to do this with variable 

SRA
Partner - Creator
Partner - Creator

I don't think so, If with some conditions you do not execute some parts of the script then tables created in the code you do not execute will be deleted from the model.

In my opinion, only the partial load will give you the possibility to keep some tables in the model without having to recalculate them. 

SRA
Partner - Creator
Partner - Creator

Hi,

Did you tried the partial reload to cover your requirement ? Was it ok ? Do you need more help on this ?

Regards,

SRA

Sivalingam
Contributor II
Contributor II
Author

Hi all I found a solution, refer below this might be useful for you.

If today is Monday, I am loading the fields from source file and storing it in another qvd file and using the stored field from that qvd file for the remaining days

IF WeekDay(Today()) = 1 //Run if today = monday

THEN
//Time(Now()) >= '04:20:00' AND Time(Now()) <= '05:00:00' THEN
Plan:
LOAD
//RowNo() as RowID, // Create a unique identifier for each row
Item,
IF(DOC > 7000,0, (Demand-QTY+SafetyStock)) as Plan1,
If(Demand > 0, ((QTY*"Working Days")/Demand), 'No Demand') as DOC_Cal

RESIDENT ItemData;
STORE Plan INTO [lib://dlpunsr002/PlanTrial.qvd] (qvd);

// Drop the original data table if it's no longer needed
DROP TABLE Plan;
EndIf

CalPlan:
LOAD

Item,
Plan1,
DOC_Cal
FROM [lib://dlpunsr002/PlanTrial.qvd] (qvd);

INNER JOIN (ItemData)
LOAD
Item,
(IF(Plan1<0 , ' ', Plan1)) as Plan,
DOC_Cal
RESIDENT CalPlan;

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

If you dont want to use partial reload part run control script statement: https://help.qlik.com/en-US/sense/November2024/Subsystems/Hub/Content/Sense_Hub/ChartLevelScripting/...

On monday part you want needs to be stored (say into QVD) and on Monday you run part of the script which runs and stores to QVD on all other days just skip that part of the script and only load table from stored QVD.

IF ...  then  ... // monday

transfrom and do whatever needs to be done on monday

store into.... qvd.

Else // all other days

load from QVD

EndIF

 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
Sivalingam
Contributor II
Contributor II
Author

Hi - can you let me know how I can run this script only on monday and that to in a stipulated time frame 

eg - time frame - 4.00am to 5.00am

Time(Now()) >= '04:20:00' AND Time(Now()) <= '05:00:00' THEN --- this is what I tried in the script, but it is not working, can you suggest any alternate method.

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

It is because now() returns timestamp including date and you compare it to time which doesnt have date in it so in reality you are comparing totally different numerical values..

to understand the issue i suggest you try and put num(now()) in table object next to num(maketime(hour,minute))

time is basically decimal value and integers are days.

 

In your case try:

Frąc(Now()) >= maketime(4,20) AND Frac(Now()) <= maketime(5) THEN

Also… i am not sure about AND in control statements. Maybe you will need to nest it instead

 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.