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

Calculate and block data in powerapps, except

Hello guys, I'm working on an app and I need to block some dates on this app.

 

Here's the question:

 

 

The user will be blocked after six business days.

 

 

But I want to calculate when it’s a holiday, a weekend, he doesn’t count those days, would that be possible?

2 REPLIES 2
Highlighted
Microsoft
Microsoft

Re: Calculate and block data in powerapps, except

Hi @Gorilla_8 :

The key is to find the 6th working day after the specified date.

Firstly,We can use the following formula to exclude weekends:

 

!(Weekday(thedate) in [1,7])

 

Secondly, if you need to exclude holidays, you need a table to store all holiday days, like:

 

[Date(2020,8,4),Date(2020,8,5),Date(2020,8,6)] /*I assume these three days are holidays 2020/8/4,2020//5,2020/8/6*/

 

The code would be:

 

!(thedate in [Date(2020,8,4),Date(2020,8,5),Date(2020,8,6)])

 

 Thirdly, to find the sixth working day after a specific date, I choose to traverse the 14 days after the specified date until the sixth working day is found.

Add a button and set it's OnSelect Property to:

 

Set(startdate,Today());/*I assume the specified date is today(2020/8/3)*/
Clear(thecollection);/*thecollection is my custom collection*/
ForAll(
    [1,2,3,4,5,6,7,8,9,10,11,12,13,14],/*Traverse 14 days*/
    If(!(Weekday(DateAdd(startdate,Value,Days)) in [1,7]) /*Exclude weekends*/
    &&
    !(DateAdd(startdate,Value,Days) in [Date(2020,8,4),Date(2020,8,5),Date(2020,8,6)]),/*Exclude holiday*/
    Collect(thecollection,
    {TheDate:DateAdd(startdate,Value,Days)})));/*Store working days in thecollection*/
Set(enddate,Last(FirstN(thecollection,6)).TheDate) /*Take the sixth record in the collection,to ger the 6th business day*/

 

After performing the above operations, the sixth payday will be stored in the variable enddate.

23.gif

Best Regards,

Bof

Highlighted
Post Prodigy
Post Prodigy

Re: Calculate and block data in powerapps, except

Ow, obrigado pela resposta rápida @v-bofeng-msft 

 

You are amazing! I will try here, and soon I will give a feedback! 

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,318)