Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Calculation over rows with condition

Hello all.   I am trying to improve a file I have worked on. I need some calculations over rows with a condition, and I was not able to do them on the interface (DAX), so I created different tables...
  • Anonymous's avatar
    Anonymous
    8 years ago

    Hi Anonymous,

     

    If you want to get the summaried stop time you can try to add new measure with below formula:

    Stop time(Summaried) =
    VAR temp =
        ADDCOLUMNS (
            ALL ( Trips ),
            "Stoped Time", LOOKUPVALUE (
                Trips[TripEndDateTime],
                Trips[VehicleID], [VehicleID],
                Trips[Date], [Date],
                Trips[Index], [Index] - 1
            )
        )
    RETURN
        SUMX (
            ADDCOLUMNS (
                FILTER ( temp, [VehicleID] = MAX ( [VehicleID] ) && [Date] = MAX ( [Date] ) ),
                "Diff", DATEDIFF ( [Stoped Time], [TripStartDateTime], SECOND )
            ),
            [Diff]
        )

     

    Regards,

    Xiaoxin Sheng