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.
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);
)
Thank you in Advance

Report
All responses (
Answers (