Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello All,
I have below data :-
[DATE_LABELS]:
LOAD DATEKEY AS DATE_LABELS.DATEKEY,
DATE(DATE#(DATEKEY,'YYYYMMDD'),'DD-MMM-YY') AS [REPORT DATE],
PERIOD_TYPE AS DATE_LABELS.PERIOD_TYPE,
DATE_LABEL,
THEDATE,
ENDDATE,
SORT_ORDER,
DATEKEY&PERIOD_TYPE AS DATE_LABEL_KEY;
SELECT "DATEKEY",
"PERIOD_TYPE",
"DATE_LABEL",
"THEDATE",
"ENDDATE",
"SORT_ORDER"
FROM "ENTERPRISE_EPR"."PPL_SBDB_DATE_LABELS";
Now, in this Report Date has data for 15th june and data is reloaded and stored into qvd. Now, when the data is reloaded next day, so it before loading it should check if the report_date has the data for 16 th june. if yes, the old data should be overwrite the new one , if not , no change should be there and the qvd should stick with the data for 15 june.
Initially I was thinking to use incremental insert and update but it is not applicable in my case as I don't want the table to be loaded until the condition for date is met.
What I have done for far is :-
1)I loaded the data table and stored it into qvd named History.qvd and calculated max(date) and stored in in the variable like below :-
Max:
Load Max(Report _Date) as Max Date
Resident Data Label
Vmax = peek ('Max Date', Max ) // this max date is calculated on the history.qvd
Drop table Data Label
2) secondly I again loaded Data label table and this time I only loaded Date field and again calculated max(date) and stored into today .qvd
Now, I what I am trying to do is create an if condition before the load of data label table that will check the maxdate of history .qvd and will check if it is greater than or equal to the maxdate calculated from today.qvd
The problem I am facing here is how should I apply this if condition so that the data is only reloaded when the condition is met. Also, not sure if my approach is correct.
Please help .
Thanks in advance
Hi,
you can create if condition in the similar way as you us it inside load statement, but with a bit different expression:
LET vMax1 = 1;
LET vMax2 = 1;
IF $(vMax1)<=$(vMax2) THEN
1:
load *inline
[temp,
1];
ELSE
2:
load *inline
[temp,
2];
END IF
so your logic can be, to calculate Vmax from history.qvd (variable vMax1), calculate your max(date) from today.qvd and store it as variable too (vMax2). And inside IF condition compare them - if it is TRUE, THEN you load something you need, if ELSE you can go straight to END IF and do nothing, or do something else (as in example, load table '2'). Note, that IF and THEN words should be in one, same row, otherwise Qlik think it is an error. Hope you can use something of this for your solution.