I seem to be having an issue with the leave request app not calculating the proper amount of requested leave days.
It was fine the other day, & I've even tried to revert back to a version that was way back in the past to ensure it's not something I've put in the code etc, but even that version seems to be doing it.
Essentially when I go to add a leave request, even with one day selected it sets the request as -3 days, effectively giving the user 3 more vacation days to use, instead of taking one away.
Does anyone have any idea what's going off?
I am able to reproduce your issue. I just tested with Leave Request sample app. My current balance is 10 days. I selected the leave date from 5/10 to 5/16, and in the next screen, New balance should be 3 days, but it shows 5 days instead.
Currently, you could work around this issue by changing the HtmlText property of the SubmitNewBalance Label control to:
"<div style='text-align:right'><font color=#4a4a4a>New balance: <b>" & If( (LookUp(RequesterBalanceCollection, type=NewLeaveTypeSelected, balance) - Value(EditRequestDays)) = 1, "1 day", LookUp(RequesterBalanceCollection, type=NewLeaveTypeSelected, balance) - Value(EditRequestDays) - 2 & " days" ) & "</b></font></div>"
And change other related wrong calculated dates and so on. Though this is not the right solution. I will try to test more later to see where the issue is.
I'm glad it's not just me. Is there any progress on a fix for this at all yet? It did work fine originally, so it seems a recent update to PowerApps must have broken it or something?
Here's an example of what I'm still seeing:
On the manager approval side:
In the excel sheet:
Any updates on this?
Looks like the formula on side "SubmitToScreen" (OnVisible) is worng. Here is the formula:
Set(TotalWorkDaysInRequestedLeavePeriod;1+ RoundDown((DateDiff(SelectDatesContentFromDatePicker.SelectedDate; SelectDatesContentToDatePicker.SelectedDate; Days) )/ 7; 0) * 5 +
Mod(5 + Weekday(SelectDatesContentToDatePicker.SelectedDate) - Weekday(SelectDatesContentFromDatePicker.SelectedDate); 5));;
Set(NumberOfLeaveWorkDaysWithoutHolidays;CountRows(Filter(Holidays; (DateDiff(EditLeaveStartDate;DateAdd(StartDate; TimeZoneOffset(StartDate); Minutes);Days) >=0) && (DateDiff(DateAdd(StartDate; TimeZoneOffset(StartDate); Minutes);EditLeaveEndDate;Days)>=0))));;
Set(EditRequestDays; TotalWorkDaysInRequestedLeavePeriod - NumberOfLeaveWorkDaysWithoutHolidays)
I think this is the formula that gives the wrong value, and all the forumlas refering to EditRequestDays will bring the wrong value. I marked the place where the formula has the fail with BOLD text.
The formula is supposed to remove weekends and holidays from the total amount of leave days.
Hope someone here can fix this or make a new formula that works.
Tho its hard to understand what the code does. example:
Select leave from 28/06 till 3/07 (4 days).
part 1: 1+ RoundDown((DateDiff(SelectDatesContentFromDatePicker.SelectedDate; SelectDatesContentToDatePicker.SelectedDate; Days) )/ 7; 0) * 5
part 2: Mod(5 + Weekday(SelectDatesContentToDatePicker.SelectedDate) - Weekday(SelectDatesContentFromDatePicker.SelectedDate); 5));;
> Part 1 returns 3 as a value, part 2 returns 1 = 4.
This works fine unless I select the Saterday as the enddate:
Select leave from 28/06 till 30/06 (2 days).
> Part 1 returns 2 as a value, part 2 returns 1 = 3
Article that explains the code: https://powerapps.microsoft.com/en-us/blog/excluding-weekends-and-holidays-in-date-differences-in-po...
Do we have solution for this , on employee request screen it shows the correct balance but when it reaches the manager approval tab it giving wrong value .
Can any one help me to resolve the calcualtion issue .
Below is the formula applied on submit screen ( on visible )
Set(TotalWorkDaysInRequestedLeavePeriod,1+ RoundDown((DateDiff(EditLeaveStartDate, EditLeaveEndDate, Days) )/ 7, 0) * 5 +
Mod(5 + Weekday(EditLeaveEndDate) - Weekday(EditLeaveStartDate), 5));
Set(NumberOfLeaveWorkDaysWithoutHolidays, CountRows(Filter(Holidays, (DateDiff(EditLeaveStartDate, DateAdd(StartDate, TimeZoneOffset(StartDate), Minutes),Days) >=0) && (DateDiff(DateAdd(StartDate, TimeZoneOffset(StartDate), Minutes),EditLeaveEndDate,Days)>=0))));
Fill out a quick form to claim your user group badge now!
Find out where you can attend!
Features releasing from October 2019 through March 2020
Learn how to build the business apps that you need.