# QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
CUSTOMERS ONLY: Now accepting customer applications for the 2023 Luminary Program: SUBMIT NOW
cancel
Showing results for
Did you mean:
Contributor III

## If condition in Load statement

CustID, Max_Sales_Date

2, 2/14/2013

3, 6/4/2015

5, 1/5/2016

6, 1/24/2017

13

14

];

4 Replies

Try this way Bucket Creation In List Box

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)
Master II

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.
Contributor III
Author

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'

Champion III

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:

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;

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