cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Resolver I
Resolver I

Forecast Due date and excluding Weekends

Hello,

 

I am working on an app that will forecast the due date of the task. 

 

I have a number field that calculates the number of Days required to finish the task based on complexity. Now, I want the total number of days to be added from Start Date.

 

StartDate + DaysofCompletion = Deadline.

 

My problem is that it does not exclude weekend. And note that the DaysofCompletion is atleast 20 Days (which is close to 3 weeks = 3 weekends (Sat & Sun))

 

I wanted to exclude every weekend it will pass from Startdate + DaysofCompletion. 

 

Kindly help me on this.


Thank you!

2 ACCEPTED SOLUTIONS

Accepted Solutions
Community Support
Community Support

Hi @anabananei ,

 

Please try with this:

 

DateAdd(
    DatePicker1.SelectedDate,
    DaysofCompletion.Text + 2 * If(
        (Weekday(
            DatePicker1.SelectedDate,
            Monday
        ) + Value(DaysofCompletion.Text)) > 7,
        RoundDown(
            (DaysofCompletion.Text - (5-Weekday(
                DatePicker1.SelectedDate,
                Monday
            ))) / 5,
            0
        ) + 1
    )
)

 

 

This code works in both cases

1. StartDate + DaysofCompletion is still in the same week

2. StartDate + DaysofCompletion is not in the same week

Snipaste_2020-06-22_14-58-47.png

Hope this helps.

Sik

View solution in original post

@anabananei ,

Please look at my post - it had this also. I did not think I had to re-paste it as it was all set out in the document for you.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

7 REPLIES 7
Super User III
Super User III

Hi @anabananei ,

Here is a good solution also excluding Public Holidays.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Community Support
Community Support

Hi @anabananei ,

 

Please try with this:

 

DateAdd(
    DatePicker1.SelectedDate,
    DaysofCompletion.Text + 2 * If(
        (Weekday(
            DatePicker1.SelectedDate,
            Monday
        ) + Value(DaysofCompletion.Text)) > 7,
        RoundDown(
            (DaysofCompletion.Text - (5-Weekday(
                DatePicker1.SelectedDate,
                Monday
            ))) / 5,
            0
        ) + 1
    )
)

 

 

This code works in both cases

1. StartDate + DaysofCompletion is still in the same week

2. StartDate + DaysofCompletion is not in the same week

Snipaste_2020-06-22_14-58-47.png

Hope this helps.

Sik

View solution in original post

Worked like a charm! Thank you!

 

Hi @v-siky-msft ,

 

Just a question, if I am to have a list of holidays from my country, how should I proceed with the solution?

 

Thanks,

A

@anabananei ,

Please look at my post - it had this also. I did not think I had to re-paste it as it was all set out in the document for you.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

I'll take a look. Thank you! 🙂

Hello @WarrenBelz ,

 

Thank you for your post. Upon review, the solution has identified both start date and end date. Whereas in my current solution, the app forecast exclude the weekends/holidays before forecasting the end date. What @v-siky-msft  said works for me, however, I'm confused how to incorporate the holiday list from the formula. Any help would be appreciated.

 

Thank you!

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Top Solution Authors
Top Kudoed Authors
Users online (46,752)