Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

pooja_sn
Contributor

Script

Hi,

I pulled below SQL table into qlikView:

   

StartDateEndDateQvdNameRefreshRequired
5/5/2016 0:005/10/2016 0:00NewTrades.qvdY

How can I write the script to load data from this qvd like


LOAD *
FROM
[..\QVDs\QvdName.qvd](qvd) where Date<=EndDate and Date>=StartDate;

and execute this load statement only when RefreshRequired is 'Y'.

13 Replies

Re: Script

Perhaps This

LOAD * FROM

[..\QVDs\QvdName.qvd](qvd) where Date<=EndDate and Date>=StartDate and RefreshRequired = 'Y';


OR


Here, What do you want to achieve the DAte

LOAD * FROM

[..\QVDs\QvdName.qvd](qvd) where RefreshRequired = 'Y';



Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

Re: Script

Hi,

What is RefreshRequired is this a variable or the field

1. If it is variable then


If RefreshRequired = 'Y' Then


LOAD *

FROM

[..\QVDs\QvdName.qvd](qvd) where Date<=EndDate and Date>=StartDate;


End If


2. If it is field


LOAD *

FROM

[..\QVDs\QvdName.qvd](qvd)

where

Date <= EndDate and Date >= StartDate

and RefreshRequired = 'Y';



Regards

Anand


Re: Script

Anand, She don't have Date Field, How she Give the restrict for StartDate and EndDate using Date Field. Share me thiughts if you have time?

OR This also Help you

LOAD *,

          Interval(Floor(EndDate - StartDate)) as Date

FROM

[..\QVDs\QvdName.qvd](qvd)

where

Date <= EndDate and Date >= StartDate

and RefreshRequired = 'Y';

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

Re: Script

Does the data from SQL will always pull one row? Would you be able to share a sample with expected output?

pooja_sn
Contributor

Re: Script

Yes.This table will return one row always.

Highlighted
pooja_sn
Contributor

Re: Script

I wish to load the data from QVD which lies within the date limits only when RefreshRequired flag is 'Y'

ionutbos
New Contributor

Re: Script

Something like this?

let vStart = peek('StartDate',0,'T1');

let vEnd = peek('EndDate',0,'T1');

let vRefresh = peek('RefreshRequired',0,'T1');

let vQVD = peek('QvdName',0,'T1');


//where T1 is the name of the table which contains those fields


If vRefresh = 'Y' Then


    LOAD *

    FROM

    [..\QVDs\$(vQVD)](qvd) where $(vStart)<= Date and Date<=$(vEnd);


End If


katla_babu
New Contributor III

Re: Script

This might solve your problem.

DataReload:

load * inline [

StartDate, EndDate, QvdName, RefreshRequired

5/5/2016 0:00, 5/10/2016 0:00, NewTrades.qvd, Y

];

vRefreshrequired= peek('RefreshRequired',0,'DataReload');

if '$(vRefreshrequired)'='Y' then

vQVDname= peek('QvdName',0,DataReload);

vstartdate= peek('StartDate',0,DataReload);

venddate= peek('EndDate',0,DataReload);

load *

  FROM

[..\QVDs\$(vQVDname)](qvd)

where Date<=$(venddate) and Date>=$(vstartdate);

end if;

Re: Script

Where is the Date field here is it available into the database, Please explain bit more clear with an example or the script.

Regards,

Anand