cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DAVIDPOWELL
Post Prodigy
Post Prodigy

Calculate working days from todays date from a variable in hours

I need a label or textbox to display

from a calculation so many days from todays date based on a hour value("dwn_Tasks.Selected.ServiceLevel_hours") in a dropdown

Excluding weekends

(8 hour working day)

So if the value from the dropdown is 72 hours(4 days)from todays date ;

the date displayed would be   2020-7-13  yyyy-m-d

 

Thanks

Dave

1 ACCEPTED SOLUTION

Accepted Solutions
v-siky-msft
Community Support
Community Support

Hi @DAVIDPOWELL ,

 

I feel confused with your requirement:

Why do 72 hours mean 4 days? Is it a mistake

What is the start day of the week? Sunday, isn't it?


If my assumption is right, Please try to set the Text property of label as follows,

Text(
    DateAdd(
        Now(),
        dwn_Tasks.Selected.ServiceLevel_hours/24 + 2 * If(
            (Weekday(
                Now(),
                StartOfWeek.Sunday
            ) + dwn_Tasks.Selected.ServiceLevel_hours/24) > 5,
            RoundDown(
                (dwn_Tasks.Selected.ServiceLevel_hours/24 - (5-Weekday(
                    Now(),
                    StartOfWeek.Sunday
                ))) / 5,
                0
            ) + 1
        )
    ),
    "[$-en-US]yyyy-m-d"
)

Snipaste_2020-07-08_15-23-19.png

Hope this helps.

Sik

 

 

View solution in original post

4 REPLIES 4
JayMagness
Solution Specialist
Solution Specialist

v-siky-msft
Community Support
Community Support

Hi @DAVIDPOWELL ,

 

I feel confused with your requirement:

Why do 72 hours mean 4 days? Is it a mistake

What is the start day of the week? Sunday, isn't it?


If my assumption is right, Please try to set the Text property of label as follows,

Text(
    DateAdd(
        Now(),
        dwn_Tasks.Selected.ServiceLevel_hours/24 + 2 * If(
            (Weekday(
                Now(),
                StartOfWeek.Sunday
            ) + dwn_Tasks.Selected.ServiceLevel_hours/24) > 5,
            RoundDown(
                (dwn_Tasks.Selected.ServiceLevel_hours/24 - (5-Weekday(
                    Now(),
                    StartOfWeek.Sunday
                ))) / 5,
                0
            ) + 1
        )
    ),
    "[$-en-US]yyyy-m-d"
)

Snipaste_2020-07-08_15-23-19.png

Hope this helps.

Sik

 

 

View solution in original post

@v-siky-msft,

Sunday may be the first day of the week, but is not considered a workday. Nor Saturday.

 

But thanks will test the formula.

 

Dave

Great! and thanks. I can work with this.

dave

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (958)