Forum Discussion

Mike22's avatar
Mike22
Helper III
7 years ago
Solved

Date difference between workflow actions on a table

  Hello Community, I need your help please.  I have the following table tracking the workflow actions for each document ID keeping track of the sequence number, who is pending action and the date ...
  • v-jiascu-msft's avatar
    v-jiascu-msft
    7 years ago

    Hi Mike,

     

    Please download the demo from the attachment. Adding a new column could make it easy.

    DaysCost =
    VAR currentId = [ID]
    VAR currentRequest = [Request]
    VAR currentSeq = [Sequence number]
    VAR currentActor = [Pending action from]
    VAR nextDate =
        CALCULATE (
            MIN ( Table1[Approved Date] ),
            FILTER (
                Table1,
                Table1[Sequence number]
                    = currentSeq + 1
                    && [ID] = currentId
                    && Table1[Request] = currentRequest
            )
        )
    VAR nextActor =
        CALCULATE (
            MIN ( Table1[Pending action from] ),
            FILTER (
                Table1,
                Table1[Sequence number]
                    = currentSeq + 1
                    && [ID] = currentId
                    && Table1[Request] = currentRequest
            )
        )
    RETURN
        IF (
            [Pending action from] = nextActor
                && nextDate = [Approved Date],
            0,
            CALCULATE (
                SUM ( 'Calendar'[ifWorkday] ),
                FILTER ( 'Calendar', [Date] >= [Approved Date] && [Date] <= nextDate )
            )
        )
    

    Date-difference-between-workflow-actions-on-a-table2

     

    Best Regards,