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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,812)