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 / Leave Request App: Cal...
Power Apps
Unanswered

Leave Request App: Calculate and Subtract Days of Leave depending on the Workdays (Monday-Sun, etc) of an Employee

(0) ShareShare
ReportReport
Posted on by

Hi,

I am new to PowerApps and I need your help.

I'm using this code here to calculate and subtract the weekends from the date range selected. This is working fine in removing the weekends.

Then I have added a new function that controls an employee workdays. [Monday - Sunday], Some Employees have a working days of Monday-Saturday. some have full week. Regulars are Mon-Fri.
I have a column saved in Sharepoint choice column as Workdays.

exec_0-1632998181343.png

 

I'd like to add a new condition where if the App matches an employee with Saturday work.

When that employee (mon-sat worker) files a leave and the date range selected covers a weekend. I would like the app to only deduct the Sunday instead of subtracting both weekends. I am confused of where I could do that condition and how should I do it.

Can someone please help.

 

//**** DETERMINE TOTAL WORK DAYS REQUESTED ****
If(
 LeaveFromDate.Value <= LeaveToDate.Value && rdoLeaveType.Selected.Value <> "Maternity/Paternity" ,
 Set(_inclusiveTotalDaysRequested, DateDiff(LeaveFromDate.Value, LeaveToDate.Value, Days) + 1);
 Set(_numFullWeeks, RoundDown(_inclusiveTotalDaysRequested / 7, 0));
 Set(_numFullDaysPartialWeek, _inclusiveTotalDaysRequested - _numFullWeeks * 7);
 Concurrent(Set(_startWeekday, Weekday(LeaveFromDate.Value)), Set(_endWeekday, Weekday(LeaveToDate.Value)));
 
 //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(_leaveLength, If(ddLeaveLength.Selected.Value ="Full Day", 0, 0.5));
 Set(_workDaysInRequest, _numFullWeeks * 5 + _numPartialWeekdays);
 
 Set(_holidaysInRequest, CountIf(HolidaysCol, 'Holiday Date' >= LeaveFromDate.Value, 'Holiday Date' <= LeaveToDate.Value));
 Set(_requestedDays, (_workDaysInRequest - _holidaysInRequest) - _leaveLength),

 //Count whole week for maternity paternity leave
 Set(_requestedDays, DateDiff(LeaveFromDate.Value, LeaveToDate.Value, Days) + 1);
)

 

exec_1-1632998776566.png

 

Thank you in Advance

Categories:

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard