Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

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.
Not applicable

Scripting problem.

How do I write an expression with conditions?

I have two date fields (referred and qualified). I want to write an experssion that says:

if the referred date field has an entry and the qualified date field has an entry, then do sum(qualified date) - sum(referred date) / count(qualified date - refererred date).

Example:

ConsumerReferred DateQualified Date
A1/1/20111/3/2011
B1/12011
C1/1/20111/5/2011

So only A and C would be selected, giving : ((1/3/2011) - (1/1/2011)) / (2)

1 Reply
deepakk
Valued Contributor III

Re: Scripting problem.

hi,

I would suggest the following method

At script level

Load Consumer ,Referred Date, Qualified Date,if( len(trim([Referred Date])) >0,'Y','N') as Ref_Ind,

if( len(trim([Qualified Date])) >0,'Y','N') as Qualifed_Ind

from Table;

At epression it would be

sum({<Ref_Ind={"Y"},Qualifed_Ind={"Y"}>}qualified date) - sum({<Ref_Ind={"Y"},Qualifed_Ind={"Y"}>}referred date) / count({<Ref_Ind={"Y"},Qualifed_Ind={"Y"}>} qualified date - refererred date)

I hope the above code helps.

Deepak

Community Browser