Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Llewbear
Advocate I
Advocate I

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 the person in (Assuming there is only one person in the house)? 

2 How long has he/she been in this room?

3. Are they active or idle within this room (count of sensor activity)?

 

I thought that 1 may be solved with some timestamped calculated column that updates when a motion sensor triggers in a new room. For 2 Might be the DateDiff between first and last time the sensor triggered and 3 Might be a simple Count of motion sensor events during the period.

 

So the logic I was trying to follow was to calculate the MIN and MAX of the DateTime for each room, from each location (there are more than one location in the data and then measuring the difference between the min and max times.

 

NB!! This approach unfortunately doesn't take into account, the time spent when moving from one room to another.

 

When I use the calculation: Motion Sensor MIN = CALCULATE(MIN ( Motion[Time(no secs)]), ALLEXCEPT ( Motion, Motion[Date], Motion[Location], Motion[Room] )), it does not take into account when a person goes from a Living Room to a Bathroom back to the Living Room.

 

My data is as follows:

RoomLocationStatusDateDateTimeTimeTime(no secs)
Living RoomLocation 1active2018/05/162018/05/16 00:1400:14:3500:14
Living RoomLocation 1active2018/05/162018/05/16 00:3100:31:0900:31
Living RoomLocation 1inactive2018/05/162018/05/16 17:4317:43:0417:43
Living RoomLocation 1inactive2018/05/162018/05/16 18:5218:52:4718:52
Living RoomLocation 1active2018/05/162018/05/16 19:3819:38:5219:38
Living RoomLocation 1inactive2018/05/162018/05/16 20:5320:53:0720:53
Living RoomLocation 1active2018/05/162018/05/16 21:1921:19:3021:19
FL6 BathroomLocation 1inactive2018/05/162018/05/16 21:3321:33:3821:33
FL6 BathroomLocation 1inactive2018/05/162018/05/16 21:3721:37:5021:37
Living RoomLocation 1inactive2018/05/162018/05/16 23:4523:45:1523:45
Living RoomLocation 1inactive2018/05/172018/05/17 10:0010:00:2410:00
Living RoomLocation 1active2018/05/172018/05/17 10:3410:34:2810:34
Living RoomLocation 1inactive2018/05/172018/05/17 11:0211:02:0811:02
Living RoomLocation 1active2018/05/172018/05/17 11:0911:09:5511:09
Living RoomLocation 1active2018/05/172018/05/17 11:2611:26:2611:26
Living RoomLocation 1active2018/05/172018/05/17 12:1612:16:3912:16
Living RoomLocation 1active2018/05/172018/05/17 12:2312:23:1312:23
Living RoomLocation 1inactive2018/05/172018/05/17 14:4514:45:0614:45
Living RoomLocation 1inactive2018/05/172018/05/17 15:5915:59:2315:59
Living RoomLocation 1active2018/05/172018/05/17 16:2116:21:0116:21
Living RoomLocation 1inactive2018/05/172018/05/17 17:2917:29:2017:29
Living RoomLocation 1inactive2018/05/172018/05/17 18:0018:00:3418:00
Living RoomLocation 1active2018/05/172018/05/17 18:0018:00:1818:00
Living RoomLocation 1inactive2018/05/172018/05/17 19:2119:21:3819:21
Living RoomLocation 1inactive2018/05/172018/05/17 20:4320:43:4320:43
Living RoomLocation 1active2018/05/172018/05/17 21:4121:41:3621:41
Living RoomLocation 1active2018/05/172018/05/17 21:5721:57:5921:57
Living RoomLocation 1active2018/05/172018/05/17 22:1722:17:4722:17
Living RoomLocation 1active2018/05/182018/05/18 08:1108:11:0208:11
Living RoomLocation 1active2018/05/182018/05/18 08:4608:46:5308:46
Living RoomLocation 1inactive2018/05/182018/05/18 09:0809:08:5909:08
Living RoomLocation 1active2018/05/182018/05/18 10:0610:06:1810:06
Living RoomLocation 1active2018/05/182018/05/18 11:0011:00:0211:00
Living RoomLocation 1active2018/05/182018/05/18 11:5111:51:1811:51
Living RoomLocation 1inactive2018/05/182018/05/18 11:5811:58:2611:58
Living RoomLocation 1inactive2018/05/182018/05/18 16:2616:26:4916:26
Living RoomLocation 1active2018/05/182018/05/18 18:4418:44:4718:44
Living RoomLocation 1inactive2018/05/182018/05/18 18:5018:50:3718:50
Living RoomLocation 1inactive2018/05/182018/05/18 18:5718:57:2018:57
Living RoomLocation 1inactive2018/05/182018/05/18 19:0019:00:1719:00
Living RoomLocation 1inactive2018/05/182018/05/18 19:0419:04:1719:04
Living RoomLocation 1inactive2018/05/182018/05/18 19:0919:09:4619:09
FL6 BathroomLocation 1inactive2018/05/182018/05/18 21:1621:16:4521:16
FL6 BathroomLocation 1active2018/05/182018/05/18 21:2121:21:2321:21
Living RoomLocation 1inactive2018/05/192018/05/19 01:0901:09:4801:09
Living RoomLocation 1inactive2018/05/192018/05/19 01:1601:16:0501:16
Living RoomLocation 1inactive2018/05/192018/05/19 01:2201:22:1401:22
Living RoomLocation 1inactive2018/05/192018/05/19 10:0810:08:0710:08
Living RoomLocation 1inactive2018/05/192018/05/19 10:2810:28:3810:28
Living RoomLocation 1active2018/05/192018/05/19 10:2810:28:2610:28
Living RoomLocation 1inactive2018/05/192018/05/19 14:3714:37:3314:37
Living RoomLocation 1inactive2018/05/192018/05/19 14:5914:59:1314:59
Living RoomLocation 1inactive2018/05/192018/05/19 17:5917:59:0417:59
Living RoomLocation 1inactive2018/05/192018/05/19 18:2418:24:3918:24
Living RoomLocation 1inactive2018/05/192018/05/19 20:3920:39:3220:39
Living RoomLocation 1active2018/05/192018/05/19 22:0222:02:0322:02
Living RoomLocation 1active2018/05/192018/05/19 23:4523:45:2823:45

 

Any guidance you can give in this regard would be very much appreciated!!

 

Thank you and have a wonderful day.

 

Kind Regards,

LlewBear

1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

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
    )


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

10 REPLIES 10

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.