Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
don_qlikview
Creator
Creator

Conditional Creation of QVD's

Hello Everyone,

I am new to qlikview and I am trying to create QVD's based upon conditional evaluation of a field. For example I am having a field called

Run Time

02/02/2014 11:00:00 AM

So, I want to make a qvd based upon the time stamp. So, I am writing something like

if(TimeStamp([Run Time], 'hh:mm:ss' = '11:00:00') then

Store abc into 11AM.qvd;

else

if(TimeStamp([Run Time], 'hh:mm:ss' = '12:00:00') then

Store abc into 12PM.qvd;

end if;

Can anyone tell me if I am writing this correctly?

Thanks,

Don

1 Solution

Accepted Solutions
Anonymous
Not applicable

Don

Instead of an IF statement how about setting a variable to the value of the Hour and using that to define the qvd name ?

// Instead of '02/02/2014 11:00:00 AM' use your field name {Run Time]

let Run Time= Hour(date#('02/02/2014 11:00:00 AM' , 'DD/MM/YY hh:mm:ss TT') ) ;


// the trace function displays the value of variable vHour when reloading

trace $(vHour) ;

//

// I prefer 24 hour clock hour, so that is what this is using and the value of vQVD is 11.qvd

let vQVD = '$(vHour)' & '.qvd' ;


// the trace function displays the value of variable vQVD when reloading

trace $(vQVD) ;

// this stores resident table abc into a qvd called 11.qvd

store abc into $(vQVD) [qvd] ;

Best Regards,     Bill

View solution in original post

4 Replies
Anonymous
Not applicable

Don

Instead of an IF statement how about setting a variable to the value of the Hour and using that to define the qvd name ?

// Instead of '02/02/2014 11:00:00 AM' use your field name {Run Time]

let Run Time= Hour(date#('02/02/2014 11:00:00 AM' , 'DD/MM/YY hh:mm:ss TT') ) ;


// the trace function displays the value of variable vHour when reloading

trace $(vHour) ;

//

// I prefer 24 hour clock hour, so that is what this is using and the value of vQVD is 11.qvd

let vQVD = '$(vHour)' & '.qvd' ;


// the trace function displays the value of variable vQVD when reloading

trace $(vQVD) ;

// this stores resident table abc into a qvd called 11.qvd

store abc into $(vQVD) [qvd] ;

Best Regards,     Bill

hic
Former Employee
Former Employee

Bill's suggestion is a good one, but first you must convert your field [Run Time] into a variable. Fields are not directly accessible from a position outside a Load statement. One way to do this is to use the Peek() function. If you want to use the time stamp from the last record, you should write

     Let vTimeStamp = Peek('Run Time',-1,'TableName') ;

or

     Let vHour = Hour(Peek('Run Time',-1,'TableName')) ;

and then use the variable in your Store statement.

HIC

don_qlikview
Creator
Creator
Author

Thanks Bill. This Worked!!!

don_qlikview
Creator
Creator
Author

Thanks Henric!!!