Forum Discussion

Llewbear's avatar
Llewbear
Icon for Advocate I rankAdvocate I
8 years ago
Solved

Time Spent in each room

Good day,   I have a similar to THIS POST, where I'm also trying to address with ALLEXCEPT(), however mine has a little twist.    I'm trying to answer the following questions:   1 What room is ...
  • Stachu's avatar
    Stachu
    8 years ago

    I assumed that travel time is only relevant if done the same day. If you remove the criteria of the same day, then it will work across days as well e.g. night 18/19 of May

    Travel Time =
    VAR CurrentRoom = Motion[Room]
    VAR CurrentLocation = Motion[Location]
    VAR CurrentDate = Motion[Date]
    VAR CurrentTimeStamp = Motion[DateTime]
    VAR PreviousTimeStamp =
        CALCULATE (
            MAX ( Motion[DateTime] ),
            ALL ( Motion ),
            Motion[DateTime] < CurrentTimeStamp
        )
    VAR PreviousRoomTimeStamp =
        CALCULATE (
            MAX ( Motion[DateTime] ),
            FILTER (
                ALL ( Motion ),
                Motion[DateTime] = PreviousTimeStamp
                    && Motion[Location] = CurrentLocation
                    && Motion[Room] <> CurrentRoom
            )
        )
    RETURN
        IF (
            PreviousRoomTimeStamp <> BLANK (),
            CurrentTimeStamp - PreviousRoomTimeStamp
        )