Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Load Only Latest Year from QVD

I must be having a brian cramp here....

I have a QVD that contains a field called Fiscal_Year. It has values like 2010, 2011, 2012, 2013. I always want to load only those rows for the most recent year, but I can't get it to work. It just throws an error and I have to re-open the .QVW. I just want to do this:

LOAD *

FROM MyData.QVD

WHERE Fiscal_Year=Max(Fiscal_Year);

1 Solution

Accepted Solutions
Not applicable
Author

Hi,

Try to use this code.

Maxi:

LOAD max(Fiscal_Year) as MaxYear

FROM MyData.QVD group by Fiscal_Year;

LET vMax=peek('MaxYear',0,'Maxi');

Drop table Maxi;

Data:

LOAD *

FROM MyData.QVD

WHERE Fiscal_Year='$(vMax)';

Hope this will help you.

Regards,

Nitin Jain

View solution in original post

4 Replies
MayilVahanan

Hi

when u use max() /aggregaton function..u want to use group by clause..

Try like this

Where fiscal_year = 2013;

Hope it helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
MayilVahanan

Hi

If u don't know the maximum year..then try like this

Tab1:

Load * from myfilename.qvd;

Inner join

Load max(fiscal_year) as fiscal_year, primarykeyfield resident Tab1 group by primarykeyfield;

Hope it helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

Hi,

Try to use this code.

Maxi:

LOAD max(Fiscal_Year) as MaxYear

FROM MyData.QVD group by Fiscal_Year;

LET vMax=peek('MaxYear',0,'Maxi');

Drop table Maxi;

Data:

LOAD *

FROM MyData.QVD

WHERE Fiscal_Year='$(vMax)';

Hope this will help you.

Regards,

Nitin Jain

Anonymous
Not applicable
Author

Thanks Nitin. You'd think it would simpler, but this works.