cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SaxonRix
Level: Powered On

Leave Request app is calculating days wrong...

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?

10 REPLIES 10
Community Support Team
Community Support Team

Re: Is Powerapps being buggy today? My Leave Request app is all of a sudden calculating days wrong..

Hi @SaxonRix,

 

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. 

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
SaxonRix
Level: Powered On

Re: Is Powerapps being buggy today? My Leave Request app is all of a sudden calculating days wrong..

Hi @v-monli-msft

 

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:

 

Capture.PNG

 

On the manager approval side:

Capture2.PNG

 

In the excel sheet:

Capture3.PNGCapture4.PNG

JAF
Level: Powered On

Re: Is Powerapps being buggy today? My Leave Request app is all of a sudden calculating days wrong..

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. 

 

JAF
Level: Powered On

Re: Is Powerapps being buggy today? My Leave Request app is all of a sudden calculating days wrong..

Anonymous
Not applicable

Re: Is Powerapps being buggy today? My Leave Request app is all of a sudden calculating days wrong..

Tho its hard to understand what the code does. example:

 

Select leave from 28/06 till 3/07 (4 days).

 

Set(TotalWorkDaysInRequestedLeavePeriod;

------------

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

Anonymous
Not applicable

Re: Is Powerapps being buggy today? My Leave Request app is all of a sudden calculating days wrong..

Goodwill
Level: Powered On

Re: Leave Request app is calculating days wrong...

Please send me the code where you calculate Leave selected days , am trying to crease an app but have no idea how days are selected

Anonymous
Not applicable

Re: Leave Request app is calculating days wrong...

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))));

 

 

PowerApps Staff mabolan
PowerApps Staff

Re: Leave Request app is calculating days wrong...

Hey @caburk, could you take a look at the leave request sample app and see what needs to be fixed?

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,920)