Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Karim_Khan
Creator III
Creator III

How to fetch QVDs in loop on year basis

Hi Team,

    I need  to fetch the data from multiple qvds on year wise.As of now I have the solution that if in target folder path suppose 10 qvds are there we can simply do that and currently i need data only for last two years I will get this thing by using concatenate wala thing

target qvd - 10

o/p  -  two qvds needed

  DATA:

LOAD

A,

B

FROM ....KK12016


CONCATENATE

      DATA1

LOAD

A,

B

FROM ....KK2017

    But this is static/manual activity for current result,I wanted to get the data like if current year is 2017 it should pick up 2016 and 2017

qvd when year 2018 will come at that time it should pick up 2017 and 2018 data ..so on,My current files ar saving in the belwo format

Path:--D:\Local Drive\Qlik_View\

FileName1:-KK_2000.qvd

FileName2:-KK_2001.qvd

FileName3:-KK_2013.qvd

FileName4:-KK_2014.qvd

FileName5:-KK_2016.qvd

FileName6:-KK_2017.qvd


Regards,

KK

qlikrajan

celambarasan@celambarasan

New to QlikView

KK
1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

You can try this.

For i=0 to 1

Let vYear =Year(Today()) - $(i);

Data:

Load * from KK_$(vYear).qvd(qvd);

Next

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

6 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

You can try this.

For i=0 to 1

Let vYear =Year(Today()) - $(i);

Data:

Load * from KK_$(vYear).qvd(qvd);

Next

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
CELAMBARASAN
Partner - Champion
Partner - Champion

May be the below script might help you

LET vNoOfYears = 2;//No of years to be taken

LET vMaxYear = Year(Today());//Max Year

LET vFileNamePrefix = 'FileName1:-KK_';//if it has to be any filename means use *

for i=vMaxYear-vNoOfYears+1 to vMaxYear

  LOAD '$(vQvdPath)$(vFileNamePrefix)$(i).qvd' as QVDFileName

  AutoGenerate 1;

  LOAD *, $(vMaxYear) as QVDYear

  From [$(vQvdPath)$(vFileNamePrefix)$(i).qvd] (qvd);

next i

Karim_Khan
Creator III
Creator III
Author

Thank you so much sir for always helping during project delivery time

KK
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Pleasure.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Anonymous
Not applicable

Buddy I just saw but I think you have got the answer.

Karim_Khan
Creator III
Creator III
Author

s buddy

KK