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.
knkirubakaran
New Contributor II

If condition in Load statement

Please help me to flag like below in load statement. If date field is null should be flag as 'New'

LOAD * INLINE [

    CustID, Max_Sales_Date

    2, 2/14/2013

    3, 6/4/2015

    5, 1/5/2016

    6, 1/24/2017

    13

    14

];

imglo.PNG

4 Replies

Re: If condition in Load statement

Try this way Bucket Creation In List Box

Life is so rich, and we need to respect to the life !!!
pradosh_thakur
Honored Contributor II

Re: If condition in Load statement

what the logic for the flag field ? Null i can understand but what about the others ? you calculate it from current date or you just check if it is in which year and assign flag. It will be easier to help and write the exact expression if you explain this logic .

Learning never stops.
knkirubakaran
New Contributor II

Re: If condition in Load statement

yes calculate from previous month.

Example: Current month Jan 2018

Flag like this

Jan 2017 - Dec 2017  - '1-12 months'

Jan 2015 - Dec 2016  - '13-36 months'

Jan 2013 - Dec 2014  - '37-60 months'

vishsaggi
Esteemed Contributor III

Re: If condition in Load statement

Did you mean this?

Flag like this

Jan 2017 - Dec 2017  - '1-12 months'

Jan 2015 - Dec 2017  - '13-36 months'

Jan 2013 - Dec 2017  - '37-60 months'


May be try this below and let us know. Ref taken from here : How Do I Get the Number of Months Between Two Dates?


DateFlag:

LOAD *,

     IF(MonthDiff >= 0 AND MonthDiff <= 12, '1-12Months',

     IF(MonthDiff >=12 AND MonthDiff <= 24, '13-24Months',

     IF(MonthDiff >=24 AND MonthDiff <= 36, '25-36Months',

     IF(MonthDiff >=36 AND MonthDiff <= 48, '36-48Months',

     IF(MonthDiff >=48 AND MonthDiff <= 60, '48-60Months', MonthDiff))))) AS DateFlag;

LOAD *,

     IF(ISNULL(DateField) = -1, 'Null', ((year(Today(2))*12)+month(Today(2))) - (((year(Max_Sales_Date)*12)+ month(Max_Sales_Date)))) AS MonthDiff

;

LOAD *, Alt(Date(Max_Sales_Date, 'MM/DD/YYYY'), Null()) AS DateField

       

INLINE [

       

CustID, Max_Sales_Date

2, 2/14/2013

3, 6/4/2015

5, 1/5/2016

6, 1/24/2017

13,

14,

];

Community Browser