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

Timestamp incremental load

Hi guys, 

I am trying to perform an incremental load routine, where I am trying to define the new data based on data after a certain time. I have a timestamp in the data on which I tried to define a variable "maxdate" which defines the latest date. 

I have two questions  (see below for code) : 

1) My timestamp has the column name "STIME" and is of following format: 181203 00:02 (ie.: YYMMDD hh:mm). Do I have to specify which column in the original data is my timestamp or does qlik understand through: 

SET TimestampFormat='YY.MM.DD hh:mm[.fff]';

2) Trying to implement the incremental load routing I am getting following message: 

"The following error occurred:
Field 'a' not found
The error occurred here:
?" 

debugging stops at line 27 (just below : //5.Pull new rows/delta.)

Data sample is attached, here is my current code:

 

// 1. Primary Data Load
data1:
LOAD
STIME,
//Date(Date#[STIME],'YYYY-MM-DD hh:mm'), AS STIME,
// Date(Floor([STIME])) as Date,
NE_ID,
OBJID,
CALLSETUPDURATION,
CALLSETUPSUCCESSRATIO
FROM [lib://Incremental Load/ZafacoLoad1.xlsx]
(ooxml, embedded labels, table is Zafaco181203);

//2. Create a qvd file.
store data1 into 'lib://QVD/ZafacoTest.qvd';
drop table data1;

//3. Find maximum date.
max_date:
LOAD
max(STIME) as Maxdate
FROM 'lib://QVD/ZafacoTest.qvd'(qvd);

//4. Store Maximum date in a variable.
Let Maxdate = floor(peek('Maxdate'));

//5.Pull new rows/delta.
data2:
NoConcatenate
LOAD
STIME,
NE_ID,
OBJID,
CALLSETUPDURATION,
CALLSETUPSUCCESSRATIO
FROM [lib://Incremental Load/ZafacoLoad2.xlsx]
(ooxml, embedded labels, table is Zafaco181205)
where STIME> $(Maxdate);

//6 Concatenate.
Concatenate (data2)
LOAD
STIME,
NE_ID,
OBJID,
CALLSETUPDURATION,
CALLSETUPSUCCESSRATIO
FROM [lib://QVD/ZafacoTest.qvd] (qvd);
STORE data2 into [lib://QVD/ZafacoTest.qvd] (qvd);

Labels (4)
15 Replies
dplr-rn
Partner - Master III
Partner - Master III

Your column STIME is being loaded as text. therefore the variable is null.

thats the reason for the error

QlikSenseUser1
Contributor III
Contributor III
Author


Thanks Dilipranjith for the quick response. 
How do I define STIME as date/timestamp? How do I troubleshoot? 

dplr-rn
Partner - Master III
Partner - Master III

Load STIME as timestamp using something like
Timestamp#(STIME,'YYMMDD hh:mm') as STIME,
QlikSenseUser1
Contributor III
Contributor III
Author

Thanks Dilipranjith. Unfortunately, it didn't work.  I have implemented as advised

data1:
LOAD
STIME,
Timestamp#(STIME,'YYMMDD hh:mm') as STIME,....

I am now however getting following error message: 

"The following error occurred:
Field names must be unique within table
 
Data has not been loaded. Please correct the error and try loading again"

Where am I going wrong?  Thanks in advance 
dplr-rn
Partner - Master III
Partner - Master III

remove the first one

 

data1:
LOAD
STIME,
Timestamp#(STIME,'YYMMDD hh:mm') as STIME,....

QlikSenseUser1
Contributor III
Contributor III
Author

Thanks Dilipranjith! This is progress, initial error code resolved. Im getting following error code after implementing as suggested: 

"The following error occurred:
Field 'a' not found
The error occurred here:
?"

Debugging stopped script at line 25 (after" 5.Pull new rows"
 
Code: 
 

// 1. Primary Data Load
data1:
LOAD
Timestamp(STIME,'YYMMDD hh:mm') as STIME,
NE_ID,
OBJID,
CALLSETUPDURATION,
CALLSETUPSUCCESSRATIO
FROM [lib://Incremental Load/ZafacoLoad1.xlsx]
(ooxml, embedded labels, table is Zafaco181203);

//2. Create a qvd file.
store data1 into 'lib://QVD/ZafacoTest.qvd';
drop table data1;

//3. Find maximum date.
max_date:
LOAD
max(STIME) as Maxdate
FROM 'lib://QVD/ZafacoTest.qvd'(qvd);

//4. Store Maximum date in a variable.
Let Maxdate = floor(peek('Maxdate'));

//5.Pull new rows/delta.
data2:
NoConcatenate
LOAD
//STIME,
Timestamp(STIME,'YYMMDD hh:mm') as STIME,
NE_ID,
OBJID,
CALLSETUPDURATION,
CALLSETUPSUCCESSRATIO
FROM [lib://Incremental Load/ZafacoLoad2.xlsx]
(ooxml, embedded labels, table is Zafaco181205)
where STIME> $(Maxdate);

//6 Concatenate.
Concatenate (data2)
LOAD
STIME,
NE_ID,
OBJID,
CALLSETUPDURATION,
CALLSETUPSUCCESSRATIO
FROM [lib://QVD/ZafacoTest.qvd] (qvd);
STORE data2 into [lib://QVD/ZafacoTest.qvd] (qvd);

 

 

// // Comments
// // max(timestamp(Date, 'YYYY/MM/DD hh:mm.ff')) as Maxdate

dplr-rn
Partner - Master III
Partner - Master III

isnt that the same error?
debug and check value of variable Maxdate
dplr-rn
Partner - Master III
Partner - Master III

use timestamp# not timestamp
date#/timestamp# function tell qlik a text is a date/timestamp field.
date/timestamp functions gives a formatted output
dplr-rn
Partner - Master III
Partner - Master III

Did it work?
If so mark as answered and close the thread