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 - Days w...
Power Apps
Answered

Leave Request - Days wrong

(0) ShareShare
ReportReport
Posted on by 66

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

 

 

 

 

Categories:
  • WarrenBelz Profile Picture
    156,748 Most Valuable Professional on at

    Hi @Dovetail ,

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

  • Verified answer
    CU-18081211-6 Profile Picture
    9,272 Moderator on at

    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 Profile Picture
    204 on at

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

  • Dovetail Profile Picture
    66 on at

    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)

     

    );

     

  • Dovetail Profile Picture
    66 on at

    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.

     

     

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 339 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 289

#3
Mohsin Ali Profile Picture

Mohsin Ali 228

Last 30 days Overall leaderboard