cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jo_25
Helper I
Helper I

Need help to troubleshoot a Half Day Leave formula I copied from this forum and which I modify for my needs

I need to allow Half Day Leave Option in the leave solution. I found a formula in this forum post --> Leave Template - Include half day option - Power Platform Community (microsoft.com)

 

This is the formula which I have adapted from the forum post. Instead of radio button for AM and PM for each LeaveStartDate & LeaveEndDate, I have a dropdown for them to select, "Full Day", "Half Day - AM" or "Half Day - PM". If the user select 

"Half Day - AM" or "Half Day - PM", workDaysInRequest will be set to (_numFullWeeks*5)/2+_numPartialWeekdays/2)); otherwise it will be set to _workDaysInRequest, _numFullWeeks * 5 + _numPartialWeekdays);  Please see the arguments highlighted in blue below.  

Somehow, powerapps is ignoring argument when user select "Half Day-AM" or "Half Day-PM", and workdaysInRequest is always set to argument when _workDaysInRequest, _numFullWeeks * 5 + _numPartialWeekdays);  

 

Would appreciate any help to resolve this formula so that the half day can be correctly computed. 

 

//**** 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(FullDayHalfDay_DataCard1_Value.Selected.Value="Half Day - AM" ,Set(_workDaysInRequest,(_numFullWeeks*5)/2+_numPartialWeekdays/2));
Set(_workDaysInRequest, _numFullWeeks * 5 + _numPartialWeekdays);
Set(_holidaysInRequest, CountIf(HolidaysCollection, StartDate >= LeaveStartDatePicker.SelectedDate, StartDate <= LeaveEndDatePicker.SelectedDate));
Set(_requestedDays, _workDaysInRequest - _holidaysInRequest)

//If(Radio1ForLeaveStartDatePicker.SelectedText.Value="PM" &&_startWeekday<>1&&_startWeekday<>7, Set(_numPartialWeekdays, _numPartialWeekdays-0.5));
//If(Radio2ForLeaveEndDatePicker.SelectedText.Value="AM" &&_startWeekday<>1&&_startWeekday<>7, Set(_numPartialWeekdays, _numPartialWeekdays-0.5));
)

 

@152118

@v-bofeng-msft

0 REPLIES 0

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

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