Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Time difference between different rows and columns for tasks with the same parent id

Hello jedis,   I need your help again.   I have the following dummy data:   TABLE 1 Parent id Task id Date Assigned Date Completed 888 1 8/19/2018 9:20 8/19/2018 9:55 888 2 ...
  • v-danhe-msft's avatar
    8 years ago

    Hi Anonymous,

    Based on my test, you could refer to below formula:

    Create this measure:

    Measure =
    VAR M =
        CALCULATE (
            MAX ( 'Table1'[Date Completed] ),
            FILTER ( ALL ( 'Table1' ), 'Table1'[Parent id] = MAX ( 'Table1'[Parent id] ) ),
            FILTER (
                'Table2',
                'Table2'[Department Assigned] = "Kitchen"
                    || 'Table2'[Department Assigned] = "Room Service"
                    || 'Table2'[ Department Completed] = "Kitchen"
                    || 'Table2'[ Department Completed] = "Room Service"
            )
        )
    VAR N =
        CALCULATE (
            MIN ( 'Table1'[Date Assigned] ),
            FILTER ( ALL ( 'Table1' ), 'Table1'[Parent id] = MAX ( 'Table1'[Parent id] ) ),
            FILTER (
                'Table2',
                'Table2'[Department Assigned] = "Kitchen"
                    || 'Table2'[Department Assigned] = "Room Service"
                    || 'Table2'[ Department Completed] = "Kitchen"
                    || 'Table2'[ Department Completed] = "Room Service"
            )
        )
    RETURN
        IF ( M = MAX ( 'Table1'[Date Completed] ), DATEDIFF ( N, M, MINUTE ), 0 )
    

    Result:

    You could also download the pbix file to have a view.

     

    Regards,

    Daniel He