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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (72,284)