web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Leave Request App Temp...
Power Apps
Answered

Leave Request App Template: Days Requested Calculation

(0) ShareShare
ReportReport
Posted on by 21

I'm using the Leave Request app template. The OnSelect property of start date picker is:

 

 

//**** 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)
 );
 Set(_workDaysInRequest, _numFullWeeks * 5 + _numPartialWeekdays); 
 Set(_holidaysInRequest, CountIf(Holidays, StartDate >= LeaveStartDatePicker.SelectedDate, StartDate <= LeaveEndDatePicker.SelectedDate));
 Set(_requestedDays, _workDaysInRequest - _holidaysInRequest)
)

 

 

But the 'New balance' total is counting weekends as in this example:

Screenshot 2022-12-13 122752.png

 New balance Text property is:

 

 

LookUp(RequesterBalanceCollection, type=_selectedLeaveType, balance) - _requestedDays
 &
 " days"

 

 

 

I also want to exclude holidays from list stored in the Excel data file. 

 

What's happening here?

Categories:
I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @FG33 ,

     

    I assume there is a holiday list:

    ClearCollect(
     HolidayList,
     {Date:Date(2022,12,15)}
    )

    You could use this formula to count days

    Sum(
     ForAll(
     Sequence(DateDiff(LeaveStartDatePicker.SelectedDate,LeaveEndDatePicker,Days),0,1),
     If(
     Weekday(DateAdd(LeaveStartDatePicker.SelectedDate,Value,Days)) in [0,6] ||
     Text(DateAdd(LeaveStartDatePicker.SelectedDate,Value,Days),"yyyy-MM-dd") in AddColumns(HolidayList,"Value",Text(Date,"yyyy-MM-dd")).Value
     ,
     {Count:0},{Count:1}
     )
     ),
     Count
    )

     

    Best Regards,

    Bof

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 429 Most Valuable Professional

#2
11manish Profile Picture

11manish 191 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 122 Super User 2026 Season 2

Last 30 days Overall leaderboard