cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dovetail
Helper II
Helper II

Leave Request - Days wrong

Hi There,

I have a query which i hope you guys might be able to help me with.

The leave request application seems to be calculating the days requested wrongly.

When an employee requests a single day off, the applications gives them two, however when they request more days, it calculates properly.

 

I have been trying to fix this but no luck.

Dovetail_0-1600244759674.png

Dovetail_1-1600244814281.png

 

Thanks

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
gabibalaban
Dual Super User
Dual Super User

Hi @Dovetail ,

As your screen shot shows, you selected 2 days, 21 September and 22 September (not only one). If you want to select only one day please use on "To" the same day as "From" selected.

 

View solution in original post

5 REPLIES 5
WarrenBelz
Super User
Super User

Hi @Dovetail ,

What is the formula you are using to calculate the days?

gabibalaban
Dual Super User
Dual Super User

Hi @Dovetail ,

As your screen shot shows, you selected 2 days, 21 September and 22 September (not only one). If you want to select only one day please use on "To" the same day as "From" selected.

 

Krishna98
Helper V
Helper V

It Seems you have selected for two days. thats why it has decreased 2 days

Hi 

This is the calculation used to determine the 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)

 

);

 

Hi @gabibalaban 

 

Aaah - You're right.

but look at this:

Dovetail_0-1600247357258.png

I changed the 1 to a 0 and it calculates properly when requesting a single day.

Dovetail_1-1600247425873.png

Dovetail_2-1600247481817.png

The problem appears when requesting more days now.
But thank you for this. I will explain to the staff that they have to use on "To" the same day as "From" selected.

 

 

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (4,662)