Forum Discussion

GeorgeR1's avatar
GeorgeR1
Frequent Visitor
4 years ago
Solved

Calculating working days between two dates on different rows

I am trying to create a column that finds the number of workingdays (excluding weekends and bankholidays - I have a list of all bank holidays in a table) between Milestones but the Audit Review ID mu...
  • v-cazheng-msft's avatar
    4 years ago

    Hi GeorgeR1 

     

    According to your description, if you expect a value of 5 for the difference between 4 and 5 for Audit 123456. You can try this Calculated column.

    MilestoneDiff =

    VAR _lastdate =

        MAXX (

            FILTER (

                'Table',

                'Table'[Audit Review ID] = EARLIER ( [Audit Review ID] )

                    && 'Table'[Milestone Type] < EARLIER ( [Milestone Type] )

            ),

            'Table'[Milestone End Date]

        )

    VAR internal =

        DATEDIFF ( _lastdate, 'Table'[Milestone End Date], DAY )

    RETURN

        IF ( ISBLANK ( internal ), BLANK (), internal + 1 )

     

    And the result should look like this.

    As you can see, there is a negative value, which I’m a little bit confused. Is the date 4/7/2021 a precise data or just a misspell? In addition, there is a weekend between 3/21/2022(4. Fieldwork & Closing Meeting) and 3/25/2022(5. Draft Report) for Audit 123456, if you would like to exclude weekends, the difference value seems to be 3 but not 5. That’s what I’m feeling unsure about.

     

    Best Regards,

    Community Support Team _ Caiyun

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!