cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Arjun1
Regular Visitor

power apps template

hi 

I was trying to integrate power apps into our company then i noticed that leave request template consider Saturday and Sunday as weekends but for my corporation only Sunday is holiday can any one help me 

i want to make saturday as a working day  

 

code 

 

//**** CALCULATION USED TO DETERMINE TOTAL WORK DAYS REQUESTED ****

 

If(LeaveStartDatePicker.SelectedDate <= LeaveEndDatePicker.SelectedDate,
Set(_inclusiveTotalDaysRequested, DateDiff(LeaveStartDatePicker.SelectedDate, LeaveEndDatePicker.SelectedDate, Days) + 1);
Set(_numFullWeeks, RoundDown(_inclusiveTotalDaysRequested / 7, 0));
Set(_numFullDaysPartialWeek, _inclusiveTotalDaysRequested - _numFullWeeks * 7);
Concurrent(Set(_startWeekday, Weekday(LeaveStartDatePicker.SelectedDate)), Set(_endWeekday, Weekday(LeaveEndDatePicker.SelectedDate)));

 

//calculates the number of business days in the partial week left over after whole weeks are subtracted out of total days requested

 

If(_numFullDaysPartialWeek = 6,
If(_startWeekday <= 2, Set(_numPartialWeekdays, 5), Set(_numPartialWeekdays, 4)
),
_numFullDaysPartialWeek = 5,
If(_startWeekday = 2, Set(_numPartialWeekdays, 5), _startWeekday = 1 || _startWeekday = 3 || _startWeekday = 4, Set(_numPartialWeekdays, 4), Set(_numPartialWeekdays, 3)
),
_numFullDaysPartialWeek = 4,
If(_startWeekday = 2 || _startWeekday = 3, Set(_numPartialWeekdays, 4), _startWeekday = 1 || _startWeekday = 4, Set(_numPartialWeekdays, 3), Set(_numPartialWeekdays, 2)
),
_numFullDaysPartialWeek = 3,
If(_startWeekday = 6 || _startWeekday = 7, Set(_numPartialWeekdays, 1), _startWeekday = 1 || _startWeekday = 5, Set(_numPartialWeekdays, 2), Set(_numPartialWeekdays, 3)
),
_numFullDaysPartialWeek = 2,
If(_startWeekday = 7, Set(_numPartialWeekdays, 0), _startWeekday = 1 || _startWeekday = 6, Set(_numPartialWeekdays, 1), Set(_numPartialWeekdays, 2)),
_numFullDaysPartialWeek = 1,
If(_startWeekday = 1 || _startWeekday = 7, Set(_numPartialWeekdays, 0), Set(_numPartialWeekdays, 1)
),
_numFullDaysPartialWeek = 0, Set(_numPartialWeekdays, 0)
);
Set(_workDaysInRequest, _numFullWeeks * 5 + _numPartialWeekdays);
Set(_holidaysInRequest, CountIf(Holidays, StartDate >= LeaveStartDatePicker.SelectedDate, StartDate <= LeaveEndDatePicker.SelectedDate));
Set(_requestedDays, _workDaysInRequest - _holidaysInRequest)
)

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @Arjun1 :

Please set the LeaveStartDatePicker's OnSelelct property to:

//**** CALCULATION USED TO DETERMINE TOTAL WORK DAYS REQUESTED ****

If(LeaveStartDatePicker.SelectedDate <= LeaveEndDatePicker.SelectedDate,
    Set(_inclusiveTotalDaysRequested, DateDiff(LeaveStartDatePicker.SelectedDate, LeaveEndDatePicker.SelectedDate, Days) + 1);
    Set(_numFullWeeks, RoundDown(_inclusiveTotalDaysRequested / 7, 0));
    Set(_numFullDaysPartialWeek, _inclusiveTotalDaysRequested - _numFullWeeks * 7);
    Concurrent(Set(_startWeekday, Weekday(LeaveStartDatePicker.SelectedDate)), Set(_endWeekday, Weekday(LeaveEndDatePicker.SelectedDate)));
    //calculates the number of business days in the partial week left over after whole weeks are subtracted out of total days requested
    If(_numFullDaysPartialWeek = 6, 
        If(_startWeekday = 2, Set(_numPartialWeekdays, 6), Set(_numPartialWeekdays, 5)
        ),
      _numFullDaysPartialWeek = 5,
        If(_startWeekday = 2 || _startWeekday = 3, Set(_numPartialWeekdays, 5), Set(_numPartialWeekdays, 4)
        ),
      _numFullDaysPartialWeek = 4,
        If(_startWeekday = 2 || _startWeekday = 3 || _startWeekday = 4, Set(_numPartialWeekdays, 4), Set(_numPartialWeekdays, 3)
        ),
      _numFullDaysPartialWeek = 3,
        If(_startWeekday = 2 || _startWeekday = 3 || _startWeekday = 4|| _startWeekday = 5, Set(_numPartialWeekdays, 3),Set(_numPartialWeekdays, 2)
        ),
      _numFullDaysPartialWeek = 2,
        If(_startWeekday = 2 || _startWeekday = 3 || _startWeekday = 4|| _startWeekday = 5 || _startWeekday = 6, Set(_numPartialWeekdays, 2),  Set(_numPartialWeekdays, 1)        ),
      _numFullDaysPartialWeek = 1,
        If(_startWeekday <> 1, Set(_numPartialWeekdays, 1), Set(_numPartialWeekdays, 0)
        ),
      _numFullDaysPartialWeek = 0, Set(_numPartialWeekdays, 0)
    );
      Set(_workDaysInRequest, _numFullWeeks * 6 + _numPartialWeekdays);  
      Set(_holidaysInRequest, CountIf(HolidaysCollection, StartDate >= LeaveStartDatePicker.SelectedDate, StartDate <= LeaveEndDatePicker.SelectedDate));
      Set(_requestedDays, _workDaysInRequest - _holidaysInRequest)
)

Best Regards,

Bof

View solution in original post

2 REPLIES 2
v-bofeng-msft
Community Support
Community Support

Hi @Arjun1 :

Please set the LeaveStartDatePicker's OnSelelct property to:

//**** CALCULATION USED TO DETERMINE TOTAL WORK DAYS REQUESTED ****

If(LeaveStartDatePicker.SelectedDate <= LeaveEndDatePicker.SelectedDate,
    Set(_inclusiveTotalDaysRequested, DateDiff(LeaveStartDatePicker.SelectedDate, LeaveEndDatePicker.SelectedDate, Days) + 1);
    Set(_numFullWeeks, RoundDown(_inclusiveTotalDaysRequested / 7, 0));
    Set(_numFullDaysPartialWeek, _inclusiveTotalDaysRequested - _numFullWeeks * 7);
    Concurrent(Set(_startWeekday, Weekday(LeaveStartDatePicker.SelectedDate)), Set(_endWeekday, Weekday(LeaveEndDatePicker.SelectedDate)));
    //calculates the number of business days in the partial week left over after whole weeks are subtracted out of total days requested
    If(_numFullDaysPartialWeek = 6, 
        If(_startWeekday = 2, Set(_numPartialWeekdays, 6), Set(_numPartialWeekdays, 5)
        ),
      _numFullDaysPartialWeek = 5,
        If(_startWeekday = 2 || _startWeekday = 3, Set(_numPartialWeekdays, 5), Set(_numPartialWeekdays, 4)
        ),
      _numFullDaysPartialWeek = 4,
        If(_startWeekday = 2 || _startWeekday = 3 || _startWeekday = 4, Set(_numPartialWeekdays, 4), Set(_numPartialWeekdays, 3)
        ),
      _numFullDaysPartialWeek = 3,
        If(_startWeekday = 2 || _startWeekday = 3 || _startWeekday = 4|| _startWeekday = 5, Set(_numPartialWeekdays, 3),Set(_numPartialWeekdays, 2)
        ),
      _numFullDaysPartialWeek = 2,
        If(_startWeekday = 2 || _startWeekday = 3 || _startWeekday = 4|| _startWeekday = 5 || _startWeekday = 6, Set(_numPartialWeekdays, 2),  Set(_numPartialWeekdays, 1)        ),
      _numFullDaysPartialWeek = 1,
        If(_startWeekday <> 1, Set(_numPartialWeekdays, 1), Set(_numPartialWeekdays, 0)
        ),
      _numFullDaysPartialWeek = 0, Set(_numPartialWeekdays, 0)
    );
      Set(_workDaysInRequest, _numFullWeeks * 6 + _numPartialWeekdays);  
      Set(_holidaysInRequest, CountIf(HolidaysCollection, StartDate >= LeaveStartDatePicker.SelectedDate, StartDate <= LeaveEndDatePicker.SelectedDate));
      Set(_requestedDays, _workDaysInRequest - _holidaysInRequest)
)

Best Regards,

Bof

View solution in original post

Thanks for the help its working now 

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

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

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 (65,641)