cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
anabananei
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
v-siky-msft
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
WarrenBelz
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.

v-siky-msft
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
User Groups Public Preview

Join us for our User Group Public Preview!

Power Apps User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.

Power Apps Community Call

Monthly Power Apps Community Call

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

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (62,508)