4 Replies Latest reply: Jan 17, 2018 11:00 AM by Vishwarath Nagaraju

# 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

];

• ###### 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 .

• ###### 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'

• ###### 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:

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,

];