Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
anushahegde
New 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

6 Replies
viveksingh
Contributor II

Re: Optimized code to fetch the maximum date from a qvd

Try Like below:

Filterdate:

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

from QVD;

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

anushahegde
New Contributor III

Re: Optimized code to fetch the maximum date from a qvd

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

Partner
Partner

Re: Optimized code to fetch the maximum date from a qvd

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
Contributor

Re: Optimized code to fetch the maximum date from a qvd

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
Support
Support

Re: Optimized code to fetch the maximum date from a qvd

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 don't forget to use the "Accept as Solution" button on any posts that helped you resolve your problem or question.
JGMDataAnalysis
Contributor II

Re: Optimized code to fetch the maximum date from a qvd

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;