Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

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?

Community Support
Community Support

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>"
    (LookUp(RequesterBalanceCollection, type=NewLeaveTypeSelected, balance) - Value(EditRequestDays)) = 1,
    "1 day",
    LookUp(RequesterBalanceCollection, type=NewLeaveTypeSelected, balance) - Value(EditRequestDays) - 2
    " days"


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. 




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.

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:




On the manager approval side:



In the excel sheet:


Frequent Visitor

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. 


Frequent Visitor

Not applicable

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

Not applicable
Not applicable

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

Not applicable

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




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

Helpful resources

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.


Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (11,527)