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 template...
Power Apps
Unanswered

Leave Request template .5 days instead of 1 full day

(0) ShareShare
ReportReport
Posted on by 72

Hello Powerapps users/ community. I need help.

 

I'm having issues with some calculation:

 

1. Calculation of half day (0.5) shows when you just click on new request, but once you scroll to the leave type and change the day, the balance shown is not affected

zmm14_2-1626324888016.png

 

2. If I select 1 DAY still shows as 0.5 days

zmm14_0-1626324618503.png

 

Categories:
I have the same question (0)
  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @zmm14,

    I noticed that you have modified the template.

    If you do not provide your modified part, it will be difficult to help you solve the problem.

    For example, what controls did you add to the template? What formulas are used?

    In addition, did you connect the template to a data source? 

    In other words, this is just a template. If It doesn't connect to the data source, the data will be reset every time you restart the app.

  • zmm14 Profile Picture
    72 on at

    Thanks for taking the time to read this.

    I follow this guide https://powerusers.microsoft.com/t5/Building-Power-Apps/Leave-Template-Include-half-day-option/td-p/787192 

    I set 2 radio controls 

    ----------------------NewRequestScreen - Radio1ForLeaveStartDatePicker - OnSelect----------------

    //**** 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)
    );
    If(Radio1ForLeaveStartDatePicker.SelectedText.Value="PM" &&_startWeekday<>1&&_startWeekday<>7, Set(_numPartialWeekdays, _numPartialWeekdays-0.5));
    If(Radio2ForLeaveEndDatePicker.SelectedText.Value="AM" &&_startWeekday<>1&&_startWeekday<>7, Set(_numPartialWeekdays, _numPartialWeekdays-0.5));
    Set(_workDaysInRequest, _numFullWeeks * 5 + _numPartialWeekdays);
    Set(_holidaysInRequest, CountIf(HolidaysCollection, StartDate >= LeaveStartDatePicker.SelectedDate, StartDate <= LeaveEndDatePicker.SelectedDate));
    Set(_requestedDays, _workDaysInRequest - _holidaysInRequest)
    )

    ------------------ConfirmationScreen - OnVisible------------------

    If(
    _submittingRequest,
    Concurrent(
    Set(
    _navMenuSelect,
    ""
    ),
    //if editing a request, revise the record that is being edited, otherwise create a new one
    Patch(
    Leave,
    If(
    _editingRequest,
    LookUp(
    Leave,
    LeaveID = GalleryRequests.Selected.LeaveID
    ),
    Defaults(Leave)
    ),
    {
    Title: TextInput1.Text,
    Detail: TextInput1_1.Text,
    StartDate: LeaveStartDatePicker.SelectedDate,
    EndDate: LeaveEndDatePicker.SelectedDate,
    LeaveType: _selectedLeaveType,
    Approver: _selectedApprover.UserPrincipalName,
    Status: "Pending",
    Requester: _myProfile.UserPrincipalName,
    LeaveID: If(
    _editingRequest,
    GalleryRequests.Selected.LeaveID,
    Text(
    Now(),
    DateTimeFormat.LongDateTime24
    ) & _myProfile.UserPrincipalName
    )
    }
    ),
    //create email template data specific to the request
    ClearCollect(
    TemplateData,
    {
    Field: "{SubmitterName}",
    Data: _myProfile.DisplayName
    },
    {
    Field: "{LeaveType}",
    Data: _selectedLeaveType
    },
    {
    Field: "{LeaveTitle}",
    Data: TextInput1.Text
    },
    {
    Field: "{LeaveDescript}",
    Data: TextInput1_1.Text
    },
    {
    Field: "{LeaveStart}",
    Data: Text(
    LeaveStartDatePicker.SelectedDate,
    "[$-en-US]mmm. dd, yyyy"
    )
    },
    {
    Field: "{LeaveEnd}",
    Data: Text(
    LeaveEndDatePicker.SelectedDate,
    "[$-en-US]mmm. dd, yyyy"
    )
    }
    )
    );
    //substitute template data values for placeholder
    ForAll(
    TemplateData,
    Patch(
    EmailTemplate,
    First(EmailTemplate),
    {
    Value: Substitute(
    First(EmailTemplate).Value,
    Field,
    Data
    )
    }
    )
    );
    //send email with email template
    Office365Outlook.SendEmailV2(
    _selectedApprover.UserPrincipalName,
    "New Leave Request",
    First(EmailTemplate).Value,
    {Importance: "Normal"}
    );

    //reset all user nput fields
    Set(
    _submittingRequest,
    false
    );
    Set(
    _leaveStart,
    Today()
    );
    Set(
    _leaveEnd,
    Today()
    );
    Set(
    _leaveTitle,
    ""
    );
    Set(
    _leaveDetail,
    ""
    );
    Set(
    _selectedLeaveType,
    Blank()
    );
    Reset(TextInput1);
    Reset(TextInput1_1);
    //reset email template to placeholder values when finished (see phone version for an alternate method of doing this)
    ClearCollect(
    EmailTemplate,
    "<html>
    <head>
    <meta http-equiv=""Content-Type"" content=""text/html; charset=us-ascii"">
    </head>
    <body>
    <p>
    There is a leave request from: {SubmitterName} pending your approval. <ul><li>Type: {LeaveType}</li><li>Title: {LeaveTitle}</li><li>Description: {LeaveDescript}</li><li>Start Date: {LeaveStart}</li><li>End Date: {LeaveEnd}</li>" & "</p>
    </body>
    </html>"
    );

    )

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 549 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 225 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 224

Last 30 days Overall leaderboard