Forum Discussion
Calculating Building Occupancy for multiple buildings based on last event by user
I am working with our facilites team to provide reports on our campus occupancy and to aid in contact tracing for illness.
I have one table showing:
| EmpID | EventTime | LocationID |
| 1 | 1/1/2022 12:00:00 PM | 1 |
| 1 | 1/1/2022 12:05:00 PM | 2 |
| 2 | 1/1/2022 12:10:00 PM | 1 |
| 2 | 1/1/2022 12:15:00 PM | 3 |
| 1 | 1/1/2022 12:30:00 PM | 1 |
| 3 | 1/1/2022 12:45:00 PM | 1 |
| 1 | 1/1/2022 1:30:00 PM | 3 |
| 2 | 1/1/2022 1:40:00 PM | 2 |
And one table showing:
| LocationID | LocationName |
| 1 | Bldg1 |
| 2 | Bldg2 |
| 3 | Bldg3 |
I need to generate a report showing the number of unique EmpID per BldgName based on their most recent EventTime. Ideally able to filter by date and EventTime grouped by hour. The intent being able to look at a building at any present or historical date and hour and see how many people were at each location - either they had activity at the location during the hour or were left in there from previous hours. Lastly, anyone in a location for more than 12 hours needs to be removed from the count. I'm a little over my head with this one, so any help would be appreciated.
Expected Result:
| Date | EventTime(Hour) | LocationName | DCountEmpID |
| 1/1/2022 | 1200 | Bldg1 | 2 |
| 1/1/2022 | 1200 | Bldg2 | 0 |
| 1/1/2022 | 1200 | Bldg3 | 1 |
| 1/1/2022 | 1300 | Bldg1 | 1 |
| 1/1/2022 | 1300 | Bldg2 | 1 |
| 1/1/2022 | 1300 | Bldg3 | 1 |
1 Reply
- v-chenwuz-msftCommunity Support
Hi Dfos25 ,
Can you explain which 2 empID are the 1200,Bldg1?
If possible, please share some example data containing all situations.
Best Regards
Community Support Team _ chenwu zhu