Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
];
Try this way Bucket Creation In List Box
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 .
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'
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,
];