Skip to main content

Notifications

Power Automate - General Discussion
Unanswered

How to Loop to Deduct Leave Balance

(0) ShareShare
ReportReport
Posted on by 997

Hi, I have this 1 list for admin to add new leave types.

anonymous21_0-1660036252263.png

Right now I'm doing if an item's status is 'Approved' in the Leave Request list, it will then subtract the leave balance for that particular employee and leave type. For example, ABC applies for a Sick Leave for 2 days and it has been approved by his approvers. ABC's original leave balance for Sick Leave is 4 days so when his application is approved, his new leave balance is 2 days. It creates issues for me to update ABC's leave balance as I can't use the switch to determine which leave type ABC has applied because the admin could be adding new ones. It also creates issues to subtract for each leave type.

How to solve these issues?

 

anonymous21_1-1660036759849.png

This is my previous method to deduct the leave balance and it uses a switch for the leave type.

 

Thank you.

 

 

 

  • Hardesh15 Profile Picture
    Hardesh15 7,087 on at
    Re: How to Loop to Deduct Leave Balance

    @syhrh  Use filter query in Get items from leave types for Leave types. When someone apply for leave, you will have leave types. Use this from trigger to get items for leave types filter and the same in Leave balance.

    Please 'Thumbs Up' the posts that helped you and 'Accept as Solution' if my post answered your question.

    @Hardesh /Gopenly.in

  • syhrh Profile Picture
    syhrh 997 on at
    Re: How to Loop to Deduct Leave Balance

    @Hardesh15 

    This is what I currently have done but it doesn't work.

    anonymous21_4-1660110786697.png

    anonymous21_6-1660110850943.pnganonymous21_7-1660110868157.png

    anonymous21_9-1660110908433.png

    I don't know how to calculate for those columns based on the leave type because previously I use a switch so it will need to fill in 2 columns only for the calculations.

     

    This is my previous calculation in another flow.

    anonymous21_10-1660110948363.png

     

    sub(items('Apply_to_each')?['EmergencyLeave'], triggerOutputs()?['body/Total_x0020_Days_x0020_Applied']) 
    add(triggerOutputs()?['body/Total_x0020_Days_x0020_Applied'],items('Apply_to_each')?['EmergencyLeaveUsed'])

     

    How to fill in the formula for all columns (the leave type) but it will only update based on the leave type modified/created by the user in the first place?

     

     

     

     

     

     

  • Hardesh15 Profile Picture
    Hardesh15 7,087 on at
    Re: How to Loop to Deduct Leave Balance

    @syhrh  Use get items for leave types and use filter query so that if it is new leave type get items will return result.

    Pls share complete flow.

    Please 'Thumbs Up' the posts that helped you and 'Accept as Solution' if my post answered your question.

    @Hardesh /Gopenly.in

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,508

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,839

Leaderboard