How to calculate available Leave day in SharePoint List

Nguyen Huu 101 Reputation points
2021-04-03T16:17:18.407+00:00

Hi All,
I create Leave request for staff by SharePoint List but i don't know how to calculate available Leave day for next request. Default staff have 12 days per year, if day left 2 days ,they will have 10 available Leave day for next request,
i put calculate available leave day by: 12- [Total day leave] but it don't work as i requirement so can you please help to share how can i put at Formula to get correct number?
84252-image.png

84251-image.png

Thanks.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,565 questions
0 comments No comments
{count} votes

Accepted answer
  1. JoyZ 18,041 Reputation points
    2021-04-27T07:26:16.617+00:00

    Hi @Nguyen Huu ,

    To avoid confusion, I will post a new reply for your reference.

    My sample list structure with column types:

    91467-image.png

    Calculated column syntax(Your available leave day and total day leave):

    91624-image.png91625-image.png

    total day leave formula:

    =IF(AND((WEEKDAY([End date],2))<(WEEKDAY([Start date],2)),((WEEKDAY([Start date],2))-(WEEKDAY([End date],2)))>1),(((DATEDIF([Start date],[End date],"D")+1))-(FLOOR((DATEDIF([Start date],[End date],"D")+1)/7,1)*2)-2),(((DATEDIF([Start date],[End date],"D")+1))-(FLOOR((DATEDIF([Start date],[End date],"D")+1)/7,1)*2)))  
    

    Flow:

    91598-image.png
    91615-image.png
    91630-image.png
    91643-image.png

    Result:

    91682-image.png
    Note:

    Since there are spaces between my column names, so the internal name will have x0020, if your column has no spaces, remember to remove it.

    You could also check the internal name of the column via list settings>click the column> check the internal name in URL like this:
    91662-image.png

    Finally, if you want to calculate half day, you need to calculate based on hours, which is difficult to achieve in the subsequent process.


    If an Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

4 additional answers

Sort by: Most helpful
  1. JoyZ 18,041 Reputation points
    2021-04-05T08:04:04.637+00:00

    Hi @Nguyen Huu ,

    Calculated fields can only operate on their own row, so we can't reference a value in another row, or columns contained in another list or library.

    So the available leave day will not be updated based on other row values.

    ----------------------------------------------------------Update------------------------------------------------------------

    As a workaround, we could create a new column named "Sum", use flow to update sum column automatically, then calculate available leave day based on this column.

    List example:

    85253-image.png

    Flow steps:

    85170-image.png
    85236-image.png
    85198-image.png

    Result:

    85255-image.png


    If an Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Nguyen Huu 101 Reputation points
    2021-04-27T08:16:43.913+00:00

    Hi @JulieWang-MSFT ,
    Thank so much for your feedback.
    as follow your steps, it work now.
    Relate to calculate half day, can we calculate by: one day =1, half day=0,5? Can we create more column " Half day", if user select Yes, that day will count 0,5 date ?
    91470-7.png91701-8.png

    Thanks.


  3. Nguyen Huu 101 Reputation points
    2021-05-20T08:24:24.85+00:00

    Hi @JulieWang-MSFT ,
    When i use " Total day leave " in "Send email with option", there are many number "0" at email notification so do you know how to remove it? and How to change the day to DD-MM-YYYY?
    98224-image.png

    98136-image.png

    Thank you so much.


  4. Santosh K Ghosh 0 Reputation points
    2023-06-20T05:58:57.0466667+00:00

    I do have similar problem, but I want once leave is approved by approver using email, a flow will run to update another sharepoint list that store the leave balance. Prompt advice and help would be appreciated.

    Presentation1

    0 comments No comments