Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Qvd separation


Hi,

I have a QVD with five weeks.i need each week as a single qvd.

ex:2013W01->1qvd

2013W02->1qvd

etc.....please find the attachment.

Thanks

1 Solution

Accepted Solutions
giakoum
Honored Contributor II

Re: Re: Re: Qvd separation

Please check out attached file

10 Replies
Not applicable

Re: Qvd separation

Try something like the following:


let vMaxWeek =  max(week(date))

let vMinWeek = min(week(date))

let QVDDirectory = 'your directory'


FOR i = $(vMinWeek) TO $(vMaxWeek)

LET t = "Week_" & ($(i));

load * from your table

where i = week(date)


STORE [$(t)] INTO [$(QVDDirectory)\DM_$(t).QVD] (qvd);

NEXT i

LET vTotalTables = NULL();
LET t = NULL();

Not applicable

Re: Qvd separation

to be precise

week(date)-> weekname(date)

LET t = "Week_" & replace(weekname($(i)),'/','') maybe...

giakoum
Honored Contributor II

Re: Qvd separation

Please see attached file :

LOAD week

FROM

C:\Users\user\Downloads\week.qvd

(qvd);

IF NoOfRows('week') > 0 THEN

  FOR j = 1 TO FIELDVALUECOUNT('week')

  LET currentWeek = FIELDVALUE('week',$(j));

  [$(currentWeek)]:

  LOAD

  '$(currentWeek)' as FilteredWeek

  AutoGenerate(1);

  STORE [$(currentWeek)] into C:\Users\user\Downloads\$(currentWeek).qvd (qvd);

  DROP Table [$(currentWeek)];

  NEXT

ENDIF

Not applicable

Re: Qvd separation

Hi Ionnis,  Thanks for your reply.I need the single qvd to be splitted into five Qvd's based on week.  Thanks Gowthami
giakoum
Honored Contributor II

Re: Qvd separation

Well that is exactly what this script does. Did you try it?

Not applicable

Re: Re: Qvd separation

Hi Ioannis

Thanks for your reply. I tried with your script, its working fine. But I am trying to do the same with the attached Qvd, am not able to generate Qvd's. Pls help me.,

Regards,

Gowthami

Not applicable

Re: Qvd separation

Try this,

If u have a date field in ur table then do likethis

YearWeek:

Load distinct Yearweek(Datefield) as weekyear from sales.qvd order by Datefield;

Rows=Noofrows(Yearweek)-1;

Startrow=0;

Do

Yearweek=Filedvalue(weekyear,$(Startrow));

Ta:

Load * fron Sales.qvd where Yearweek(Datefiled)=$(Yearweek);

Store tab into "F:\Sales_$(Yearweek)";

Startrow=Startrow+1;

while(Rows>=Startrow)

Regards,

Kabilan K.

Not applicable

Re: Qvd separation

Pls change the Yearweek() function as Weekname() in my prev reply

giakoum
Honored Contributor II

Re: Re: Re: Qvd separation

Please check out attached file

Community Browser