Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

rammuthiah
Contributor II

Load data based on max date

I tried loading data based on max date from file name.

While trying to call in a variable, it's not working.

Is there any way to loa

Capture.JPG

Tags (1)
1 Solution

Accepted Solutions
agigliotti
Honored Contributor II

Re: Load data based on max date

I think you should use a loop to load all file names in your table.

how your script do it ?

13 Replies
b_knuever
Contributor III

Re: Load data based on max date

Post your script please. We can't see what you are doing wrong like this. And yes it is possible.

rammuthiah
Contributor II

Re: Load data based on max date

///////////

Load

    date(date#(trim(left(subfield(FileName(),'DataFileName -',2),11)),'YYYY-MM-DD'),'DD-MM-YYYY') aS Source

From ExcelTable...

////////////

Let vMaxFileDate=date(max(Source,'MM/DD/YYYY'));

arunaerra
Contributor

Re: Load data based on max date

Hi

try this may be

Master:

ID,

date

from Master.qvd;

Max:

load max(date) as maxdate

resident Master;

Let  vMax = peek('maxdate',0,'Max')

Drop table Max;

Transaction:

join(Master)

Load

ID,

date

From Transaction.qvd

where date >'$(vMax)';

agigliotti
Honored Contributor II

Re: Load data based on max date

let's try below code:

table_name:

Load

    max( date(date#(trim(left(subfield(FileName(),'DataFileName -',2),11)),'YYYY-MM-DD'),'DD-MM-YYYY') ) as Source

From ExcelTable...

Let vMaxFileDate = Peek( 'Source', 0, 'table_name');

rammuthiah
Contributor II

Re: Load data based on max date

Eventhough I am getting the min date not the max Date. Here the max date is 2018-07-12

Capture.JPG

b_knuever
Contributor III

Re: Load data based on max date

where date >= '$(vMax)'; Dont forget the '=' other wise it won't find anything can even discard '>' and also using the match function here would help a little bit with performance.

agigliotti
Honored Contributor II

Re: Load data based on max date

I think you should use a loop to load all file names in your table.

how your script do it ?

rammuthiah
Contributor II

Re: Load data based on max date

In file name only I have date. based on the date have to load the maximum date file only. Help me to resolve this in script

b_knuever
Contributor III

Re: Load data based on max date

Load all file names first then get the part that has the date and max that. and then use it with wildcards to only load that date.