Wednesday, August 6, 2014

QV6 Preceding Load

What is Preceding load
- preceding load allow you define multiple transformations and calculations within one load script,
if it is not present we need to create another load or resident statement.

BENIFITS, WHY PROCEDING LOAD
- we can use multiple load using previous loaded select
- Advantage of Preceding Load is that it allows you to use QlikView functions in the Load script
  (on other hand you can not use qlikview function in SQL load query)
- USED FOR TRANSFORMATION and calculations PURPOSE
- It is also suggested to use preceding load to some scenerio, in which the qlikview function are using again and again like below example,
 1st load statement from below using date function and 2nd load statement to get the difference.
 We can also write the '1st load statement from below' as

LOAD date(CREATED_DATE,'D-MMM-YYYY') AS  [CREATED DATE] ,Today(1) AS TODAY_DATE , date(UPDATED_DATE,'D-MMM-YYYY') AS [UPDATED DATE],Today(1)-date(UPDATED_DATE,'D-MMM-YYYY') AS DIFF;


Which cause the overhead for qlikview and we are processing the data, which is calculated primarily.



1. Open Qlikview, create new document and save it.
2. Press ctrl+e (now you can see script editor)
3. create the respective ODBC connection to the database having table "flight_Data_1"
4. You can get "FLIGHT_DATA_1" create table script from post http://j4info.blogspot.in/2014/08/qv5-incremental-loading.html
5. Copy and paste below code in script editor


LOAD "PRIMARY_KEY", IF ([DAYS DIFF] > 170 , 'YES','NO'),[DAYS DIFF];
LOAD "PRIMARY_KEY", TODAY_DATE - [UPDATED DATE] AS [DAYS DIFF];
LOAD "PRIMARY_KEY",date(CREATED_DATE,'D-MMM-YYYY') AS  [CREATED DATE] ,Today(1) AS TODAY_DATE , date(UPDATED_DATE,'D-MMM-YYYY') AS [UPDATED DATE];
SQL SELECT
 "PRIMARY_KEY",
    "CREATED_DATE",
    "UPDATED_DATE",
    YEAR,
    MONTH,
    "AIRCRAFT_TYPE_ID",
    "DEPARTURES_SCHEDULED",
    "DEPARTURES_PERFORMED",
    "AVAILABLE_SEATS",
    "TRANSPORTED_PASSENGERS",
    "TRANSPORTED_FREIGHT"
FROM SCOTT."FLIGHT_DATA_1";



Now you can see in above code we have three preceding load statements. Preceding load statement execute below to up manner and order of execution is get by qlikview itself it search for the "from /Resident " clause for respective load statement until it get.
 - it load table from database using SQL SELECT query
 - First load statement converting raw date to actual date format.
 - 2nd load statement getting date difference between today date and updated date.
 - 3rd Load statement using if condition if DATEDIFF > 170 then return "yes" else "no"

 

No comments:

Post a Comment

web stats