Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
rammuthiah
Creator III
Creator III

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

1 Solution

Accepted Solutions
agigliotti
Partner - Champion
Partner - Champion

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

how your script do it ?

View solution in original post

13 Replies
bramkn
Partner - Specialist
Partner - Specialist

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

rammuthiah
Creator III
Creator III
Author

///////////

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'));

Anonymous
Not applicable

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
Partner - Champion
Partner - Champion

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
Creator III
Creator III
Author

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

Capture.JPG

bramkn
Partner - Specialist
Partner - Specialist

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
Partner - Champion
Partner - Champion

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

how your script do it ?

rammuthiah
Creator III
Creator III
Author

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

bramkn
Partner - Specialist
Partner - Specialist

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.