Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
rakeshkumar1890
Creator
Creator

Date according Business Days

Hello Everyone,

Need your help to find out Start date:

Table:

OrderLinePartsCleanedDatePlanDateOutputDate
571201578701088/7/20207/22/2020 
571201578701088/7/20207/23/2020 
571201578701088/7/20207/24/2020 
571201578701088/7/20208/3/2020 
571201578701088/7/20208/4/2020 
57120157P118888/7/20207/29/2020 
57120157P118888/7/20207/30/2020 
57120157P118888/7/20207/31/2020 
CWET1579797978/3/20208/5/20208/5/2020
CWET1579797978/3/20208/9/20208/9/2020
CWET1579797978/3/20208/10/20208/10/2020
CWET157YTR7898/4/20208/5/20208/9/2020
CWET157YTR7898/4/20208/9/20208/9/2020
CWET157YTR7898/4/20208/12/20208/12/2020

 

Here in my raw data - there are two date fields (CleanedDate and PlanDate). I Need output field with given below scenorios.

1.Need to check PlanDate to CleanedDate + 2 Business days (function - Networkdays (Monday to Friday)) ,

In below case

OrderLinePartsCleanedDatePlanDateOutputDate
571201578701088/7/20207/22/2020 
571201578701088/7/20207/23/2020 
571201578701088/7/20207/24/2020 
571201578701088/7/20208/3/2020 
571201578701088/7/20208/4/2020 

CleanedDate+2BD = 8/9/2020 and PlanDate Started From 7/22/2020 to 8/4/2020, In this case CleanedDate not present in PlanDate, hence this data should be blank.

2. Need to check PlanDate to CleanedDate + 2 Business days (function - Networkdays (Monday to Friday)) ,

In below case

CleanedDate+2BD = 8/6/2020 and PlanDate Started from 8/5/2020. In this case the PlanDate should be equal to 8/6/2020 or whatever greater is present in PlanDate.

OrderLinePartsCleanedDatePlanDateOutputDate
CWET157YTR7898/4/20208/5/2020 
CWET157YTR7898/4/20208/9/20208/9/2020
CWET157YTR7898/4/20208/12/20208/12/2020

 

Thanks in advance for your input.

Labels (2)
1 Solution

Accepted Solutions
Taoufiq_Zarra
MVP
MVP

@rakeshkumar1890  May be like this

load *,if(LastWorkDate(CleanedDate+1, 2)<PlanDate,PlanDate) as OutputDate;

LOAD OrderLine, Parts, Date#(CleanedDate,'M/D/YYYY') as CleanedDate, Date#(PlanDate,'M/D/YYYY') as PlanDate  INLINE [
    OrderLine, Parts, CleanedDate, PlanDate
    57120157, 870108, 8/7/2020, 7/22/2020
    57120157, 870108, 8/7/2020, 7/23/2020
    57120157, 870108, 8/7/2020, 7/24/2020
    57120157, 870108, 8/7/2020, 8/3/2020
    57120157, 870108, 8/7/2020, 8/4/2020
    57120157, P11888, 8/7/2020, 7/29/2020
    57120157, P11888, 8/7/2020, 7/30/2020
    57120157, P11888, 8/7/2020, 7/31/2020
    CWET157, 979797, 8/3/2020, 8/5/2020
    CWET157, 979797, 8/3/2020, 8/9/2020
    CWET157, 979797, 8/3/2020, 8/10/2020
    CWET157, YTR789, 8/4/2020, 8/5/2020
    CWET157, YTR789, 8/4/2020, 8/9/2020
    CWET157, YTR789, 8/4/2020, 8/12/2020
];

 

output:

Capture.PNG

 

8/7/2020+2BD is 11 not 9 ?

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

2 Replies
Taoufiq_Zarra
MVP
MVP

@rakeshkumar1890  May be like this

load *,if(LastWorkDate(CleanedDate+1, 2)<PlanDate,PlanDate) as OutputDate;

LOAD OrderLine, Parts, Date#(CleanedDate,'M/D/YYYY') as CleanedDate, Date#(PlanDate,'M/D/YYYY') as PlanDate  INLINE [
    OrderLine, Parts, CleanedDate, PlanDate
    57120157, 870108, 8/7/2020, 7/22/2020
    57120157, 870108, 8/7/2020, 7/23/2020
    57120157, 870108, 8/7/2020, 7/24/2020
    57120157, 870108, 8/7/2020, 8/3/2020
    57120157, 870108, 8/7/2020, 8/4/2020
    57120157, P11888, 8/7/2020, 7/29/2020
    57120157, P11888, 8/7/2020, 7/30/2020
    57120157, P11888, 8/7/2020, 7/31/2020
    CWET157, 979797, 8/3/2020, 8/5/2020
    CWET157, 979797, 8/3/2020, 8/9/2020
    CWET157, 979797, 8/3/2020, 8/10/2020
    CWET157, YTR789, 8/4/2020, 8/5/2020
    CWET157, YTR789, 8/4/2020, 8/9/2020
    CWET157, YTR789, 8/4/2020, 8/12/2020
];

 

output:

Capture.PNG

 

8/7/2020+2BD is 11 not 9 ?

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
rakeshkumar1890
Creator
Creator
Author

Big thanks Taoufiq