Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
ankit777
Valued Contributor

Conditionally creating QVD

Can I create a QVD under certain conditions?

Like if I have table With months data and i want to create the QVD only when month value is JANUARY.

8 Replies
Not applicable

Re: Conditionally creating QVD

Yes Ankit,

you can.

Just use WHERE  or IF ...THEN ...ELSE  condition

This just need to peek month to evaluate

best regards

Chris

Not applicable

Re: Conditionally creating QVD

Yes you can.. You can use where condition like SQL...



Tablename.QVD (
qvd) Where MonthName='Jan';

Thanks,

Selvakumar

Not applicable

Re: Conditionally creating QVD

Sorry Selvakumar

but this will store only records where month is january.

I think the goal is to stroe a whole qvd when the current month is january

Best regards

Chris

Not applicable

Re: Conditionally creating QVD

Create a variable for Currentmonth and use if condition before load script...

If (vCurrentMonth=Yes) then Load * from table.. else Exit Script;

You have to calculate the month you want in that variable

Selva

preminqlik
Valued Contributor II

Re: Conditionally creating QVD

hi you can try this

orginaltable :

Load *,

num(TxnDate)               as               TestDate

from xxx;

maxtable:

max(TestDate)               as          MaxDateNum

resident orginaltable;

let vMaxDate = peek('MaxDateNum',0,'maxtable');

Drop table maxtable;

let vComment=if(Month(date($(vMaxDate)))='Jan' and Year(date($(vMaxDate)))=Year(date(today())) ,' ' ,'//');

$(vComment) store orginaltable into C:\path..;

drop table orginaltable ;

or else you can use if and else loop also

regards

Premhas

ankit777
Valued Contributor

Re: Conditionally creating QVD

Hi Chris,

This is my script.

Temp:

LOAD PK_DMA_ID,

     FK_HDZ_ID,

     MAINS_LENGTH_MT, 

     Month as M

FROM

(biff, embedded labels, table is Sheet1$);

I want to create the QVD for the records of month January only. How should I use if else or where condition?

er_mohit
Honored Contributor II

Re: Conditionally creating QVD

Yes you can do it by using precedent load like this

Temp:

load * where numM = 1;

LOAD PK_DMA_ID,

     FK_HDZ_ID,

     MAINS_LENGTH_MT,

     Month as M,

num(Month) as numM

FROM

(biff, embedded labels, table is Sheet1$);

hope it helps

MVP
MVP

Re: Conditionally creating QVD

Hi Ankit,

Try like this

Temp:

LOAD PK_DMA_ID,

     FK_HDZ_ID,

     MAINS_LENGTH_MT,

     Month as M

FROM

(biff, embedded labels, table is Sheet1$)

Where Month = 'January';

** Replace January with your month name (Jan or 1 or January)

Regards,

Jagan.

Community Browser