- Home
- Guides
- Power Automate
- How to check PTO balance before approval with Power Automate, Microsoft Forms and Excel
How to check PTO balance before approval with Power Automate, Microsoft Forms and Excel
Upgrade a Microsoft Forms leave request flow so Power Automate checks the employee's PTO balance in Excel before the manager sees the request, then updates used hours automatically after approval.
Jump to a step (13)
Small teams that track PTO in a spreadsheet often send every leave request to the manager, even when the employee has no hours left. Someone then has to look up the balance by hand, reject the request, and remember to update the used hours after each approval.
This is Part 2 of the PTO leave request approval system. In Part 1 an employee submits a leave request in Microsoft Forms, the manager approves or rejects it, and every request is logged in Excel. This upgrade adds a PTO Balance table and a balance check before the approval step.
The flow looks up the employee by email address, calculates leave days and requested hours, and only sends the approval if the available hours cover the request. If not, it marks the request as Insufficient PTO Balance and emails the employee. When a request is approved, the flow adds the hours to Used PTO Hours and Excel recalculates what is left. Everything runs on Microsoft Forms, Excel in OneDrive, Office 365 Outlook and Approvals, with no SharePoint.
What you need
- Microsoft 365 Business Basic or Standard
- The working PTO approval flow from Part 1 (Microsoft Forms, Excel, Approvals)
- An Excel file in OneDrive for Business with the request tracker table
- A second table named PTO Balance with Full Name, Email Address, Hours Per Day, Total PTO Hours, Used PTO Hours and Available PTO Hours
- Each employee's row added to the PTO Balance table, with the same email they enter in the form
Step by step
0 of 13 done-
01
Add two columns to the request tracker
Open the Excel file from Part 1. In the request tracker table, add two new columns:
Leave DaysandRequested Hours.Leave Daysstores how many days the employee asked for.Requested Hoursstores how many PTO hours the request will use. For example, five days at eight hours a day is 40 hours.The form itself does not change. It still asks for full name, email address, manager's email address, leave type, start date, end date and reason for leave.
-
02
Create the PTO Balance table
In the same Excel file, create a second table and name it
PTO Balance. Add these columns:Full NameEmail AddressHours Per DayTotal PTO HoursUsed PTO HoursAvailable PTO Hours
Make
Available PTO Hoursa formula:Total PTO HoursminusUsed PTO Hours. The flow only ever updatesUsed PTO Hours, and Excel recalculates the balance.Add one row for every employee. You can change
Hours Per DayorTotal PTO Hoursby hand at any time without breaking the flow, because the flow finds each row by email address. -
03
Get the employee's PTO balance
Open the existing flow. After the step that generates the request ID, add the Excel Online (Business) action Get a row.
- Location:
OneDrive for Business - Document Library:
OneDrive - File: the same PTO tracker file
- Table:
PTO Balance - Key Column:
Email Address - Key Value:
Email Addressfrom Get response details
Rename the action to
Get PTO Balance. The flow can now read the employee's hours per day, used hours and available hours. - Location:
-
04
Calculate leave days
Add a Compose action and rename it
Leave Days. In the input, open the expression editor and enter an expression that subtracts the start date from the end date and adds one, for example:add(div(sub(ticks('EndDate'),ticks('StartDate')),864000000000),1)Replace the
EndDateandStartDateplaceholders with the End Date and Start Date answers from Get response details (dynamic content). The+1is there because the start date counts as a leave day too. -
05
Calculate requested hours
Add another Compose action and rename it
Requested Hours. Use an expression that multiplies leave days by hours per day:mul(outputs('Leave_Days'),float('HoursPerDay'))Replace the
HoursPerDayplaceholder with Hours Per Day from Get PTO Balance. Four leave days at eight hours gives 32 requested hours. -
06
Log leave days and hours in the tracker
Open the existing Add a row into a table action that writes the request to the tracker. Under Advanced parameters, show
Leave DaysandRequested Hours. Map them to the outputs of theLeave DaysandRequested Hourscompose actions.Every new request row now shows the days and hours requested.
-
07
Check available PTO hours
Before the approval, add a Condition.
- Left side (expression):
float()wrapped around Available PTO Hours from Get PTO Balance - Operator:
is greater than or equal to - Right side: the output of
Requested Hours
float()turns the Excel value into a number so Power Automate does not compare it as text. True means the employee has enough hours. False means they do not. - Left side (expression):
-
08
Move the approval into the True branch
Drag the existing approval action into the True branch of the balance condition. Then drag the approval outcome condition in after it.
Now the manager only gets an approval request when the available hours cover the request.
-
09
Show PTO details to the manager
Open the approval action. Keep the title, Assigned to (the manager's email from the form) and the original request details. Add three new lines to Details:
- Leave days: output of
Leave Days - Requested hours: output of
Requested Hours - Available PTO balance: Available PTO Hours from Get PTO Balance
The manager can now see the balance before deciding.
- Leave days: output of
-
10
Update Used PTO Hours after approval
In the approved branch, keep the existing Update a row action that sets the tracker status to Approved (key column
Request ID).After it, add a second Update a row action:
- Location:
OneDrive for Business, Document Library:OneDrive, same file - Table:
PTO Balance - Key Column:
Email Address, Key Value:Email Addressfrom Get response details - Under Advanced parameters, show
Used PTO Hours
For
Used PTO Hours, use an expression that adds the requested hours to the current used hours:add(float('UsedPTOHours'),outputs('Requested_Hours'))Replace the placeholder with Used PTO Hours from Get PTO Balance. Excel then recalculates
Available PTO Hourson its own. - Location:
-
11
Add the remaining balance to the approval email
Open the existing approval email. Add a line
Remaining PTO balance:followed by an expression that subtracts the requested hours from the available hours:sub(float('AvailablePTOHours'),float(outputs('Requested_Hours')))Replace the placeholder with Available PTO Hours from Get PTO Balance, then type
hoursafter it.The rejected branch stays the same as Part 1: it updates the tracker as Rejected with the comments and sends the rejection email.
-
12
Handle insufficient PTO balance
In the False branch of the balance condition, add Update a row. The request was already added as Pending, so you only update that row.
- Same location, library and file
- Table: the request tracker (
Table1in the video) - Key Column:
Request ID, Key Value: the request ID variable - Under Advanced parameters, set
StatustoInsufficient PTO Balance
Then add the Office 365 Outlook action Send an email (V2):
- To:
Email Addressfrom Get response details - Subject:
PTO request could not be submitted - Body: greet the employee by Full Name and list leave days, requested hours and available PTO hours
The manager is never asked to approve a request that cannot be approved.
-
13
Test both cases
Save the flow and click Test, then Manually.
First, submit a request the employee can cover. In the video a three-day request goes to the manager, who sees leave days, requested hours and available hours. After approval the tracker shows 3 days and 24 hours,
Used PTO Hoursgoes from 16 to 40, and the employee's email shows the remaining balance.Next, submit a request larger than the balance. In the video the employee has 20 hours available and asks for 40. The tracker row gets
Insufficient PTO Balance, no approval is sent, and the employee gets the "could not be submitted" email.
Tips and common problems
- If the balance comparison gives the wrong result, wrap the Excel values in
float(). Excel values often come into Power Automate as text. - If leave days are off by one, check the
+1in the Leave Days expression. The start date has to be counted as a leave day. - If Get a row cannot find the employee, the email entered in the form must exactly match the Email Address in the PTO Balance table.
- If the manager still gets a request when the employee has no balance, the approval action is outside the True branch. Drag it inside.
- Only let the flow write to Used PTO Hours. Keep Available PTO Hours as an Excel formula so the balance always recalculates.
Start with Part 1
This page upgrades an existing flow. If you have not built the base leave request approval system yet, watch Part 1: PTO Leave Request Approval System first.
Expressions used in this flow
| Action | What it does | Expression |
|---|---|---|
| Leave Days (Compose) | Days from start to end date, counting the start date | add(div(sub(ticks('EndDate'),ticks('StartDate')),864000000000),1) |
| Requested Hours (Compose) | Leave days times hours per day | mul(outputs('Leave_Days'),float('HoursPerDay')) |
| Condition (left side) | Available hours as a number | float('AvailablePTOHours') |
| Update a row: Used PTO Hours | Adds this request to used hours | add(float('UsedPTOHours'),outputs('Requested_Hours')) |
| Approval email | Remaining balance after this request | sub(float('AvailablePTOHours'),float(outputs('Requested_Hours'))) |
Replace each quoted placeholder with the matching dynamic content from Get response details or Get PTO Balance.
Questions
Can Power Automate check PTO balance before sending a leave approval?
Yes. Use Get a row to read the employee's row from an Excel PTO balance table, calculate the requested hours, and put the approval inside a condition that checks available hours are greater than or equal to requested hours.
Do I need SharePoint to build a PTO tracker in Power Automate?
No. This build uses Microsoft Forms, an Excel file in OneDrive for Business, Office 365 Outlook and Approvals, all available with standard Microsoft 365 business plans.
Does the leave days calculation skip weekends?
No. The expression in this video counts every calendar day from start date to end date, including the start date. A Friday to Monday request counts as four days.
How does the PTO balance update after approval?
In the approved branch, an Update a row action adds the requested hours to Used PTO Hours in the PTO Balance table. Available PTO Hours is an Excel formula (Total minus Used), so it recalculates on its own.
