web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Annual leave request: ...
Power Apps
Unanswered

Annual leave request: calculating days requested and updating balance for half days

(0) ShareShare
ReportReport
Posted on by 21

I've set up a radio control on annual leave request to adjust the time booked off for half-day and third-day requests.

The OnSelect property of LeaveDateStartPicker is:

//**** 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)
 );
If(Radio2forLeaveStartDatePicker.Selected.Value="Third Day - AM" && _startWeekday<>1&&_startWeekday<>7, Set (_numPartialWeekdays, _numPartialWeekdays-0.66));
If(Radio2forLeaveStartDatePicker.Selected.Value="Third Day - PM" && _startWeekday<>1&&_startWeekday<>7, Set (_numPartialWeekdays, _numPartialWeekdays-0.66));
If(Radio2forLeaveStartDatePicker.Selected.Value="Half Day - AM" &&_startWeekday<>1&&_startWeekday<>7, Set(_numPartialWeekdays, _numPartialWeekdays-0.5));
If(Radio2forLeaveStartDatePicker.Selected.Value="Half Day - PM" &&_startWeekday<>1&&_startWeekday<>7, Set(_numPartialWeekdays, _numPartialWeekdays-0.5));
 Set(_workDaysInRequest, _numFullWeeks * 5 + _numPartialWeekdays); 
 Set(_holidaysInRequest, CountIf(Holidayss, cr72e_startdate >= LeaveStartDatePicker.SelectedDate, cr72e_startdate <= LeaveEndDatePicker.SelectedDate));
 Set(_requestedDays, _workDaysInRequest - _holidaysInRequest)
);

 

The live balance counter works correctly:

 

Untitled video - Made with Clipchamp.gif

 

The request for third-day is sent for manager approval showing correctly:

 

Screenshot 2023-01-26 113712.png

 

But the half-day shows as 1 day:

 

Screenshot 2023-01-26 114133.png

 

I haven't been able to resolve this; any ideas?

Categories:
I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard