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: 
anushahegde
Contributor III
Contributor III

Optimized code to fetch the maximum date from a qvd

Hi all,

I have a qvd containing 618,994,678 records. I did the optimized qvd load and now I want to fetch the maximum date from this qvd. what is the best way to do it so that it consumes less time to give the maximum date?

 

Thank you

Anusha

Labels (3)
6 Replies
viveksingh
Creator III
Creator III

Try Like below:

Filterdate:

Load 
date(Max(DATE_COLUMN),'DD/MM/YYYY') as maxdate

from QVD;

SET vmaxdate=peek('maxdate', 0, 'Filterdate');

anushahegde
Contributor III
Contributor III
Author

Looks like Max(Date) will consume lot of time. 

andrei_delta
Partner - Creator III
Partner - Creator III

hi,

i use this code for my timeline

Temp:

LOAD num(floor(Max( [newdatefield] ))) as DataMax,
num(floor(Min( [newdatefield] ))) as DataMin;
LOAD FieldValue('yourdatefield', recno()) as [newdatefield]
AUTOGENERATE (FieldValueCount('yourdatefield'));

LET vDataMin = Peek('DataMin',-1,'Temp');
LET vDataMax = Peek('DataMax',-1,'Temp');

it's way faster than simple max() applied on the date field.

hope it helps,

Andrew

Victor_Alumanah
Creator
Creator

temp:

LOAD DATE_COLUMN

FROM

[S00.QVD]

(qvd);

MinMaxDate:

Load min(DATE_COLUMN) as MinDate,

max(DATE_COLUMN) as MaxDate;

Load FieldValue('DATE_COLUMN',IterNo()) as DATE_COLUMN

autogenerate(1)

while not IsNull(FieldValue('DATE_COLUMN',Iterno()));

Drop Table temp;

While we teach we learn
Brett_Bleess
Former Employee
Former Employee

Anusha, If the goal is to load the QVD file optimized, then do that into a Temp table as the last poster recommended and then run your addtional code against the Temp table and once you have what you need drop the Temp table from the data model.  If Victor's post was what you used to solve things, please remember to give credit and let others know things worked by using the Accept as Solution button on the post(s) that helped you get to your solution.  If you did something else, consider posting that and then mark it, and if you are still working on things, update the post with where you are with things.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
JGMDataAnalysis
Creator III
Creator III

https://qlikviewcookbook.com/2013/09/fastest-method-to-read-maxfield-from-a-qvd/

Temp:
LOAD Max(Date) AS MaxDate FROM 'YourPath.qvd' (qvd);

LET vMaxDate = Num(Peek('MaxDate', 0, 'Temp'));

DROP TABLE Temp;