Forum Discussion
AndHan
5 years agoFrequent Visitor
Calculate occupancy at specific datetime
I'm working on a Power BI project, where I'm trying to visualize occupancy on a parkinglot vs time.
A parking bay can either be Occupied or Free and only have one state at any given time.
What I would like is to visualize is how many bays were occupied at a specific time (for example yesterday at 12 am or 3pm) on a graph.
I have a datetable with all the timestamps for my X-axis.
How can I calculate what state a bay had at any given time?
When visualizing the occupancy the occupied + free bays should at all times equal the total amount of bays at the parking lot.
An example of my data is in the following format:
| bayID | status_startTime | endTime | status |
| 1 | 2020-10-13 05:37:27Z | 2020-10-13 12:02:42.6593146 +02:00 | Occupied |
| 1 | 2020-10-13 10:02:40Z | 2020-10-13 12:02:58.5031439 +02:00 | Free |
| 1 | 2020-10-13 10:02:56Z | 2020-10-13 12:04:03.1440793 +02:00 | Occupied |
| 2 | 2020-10-13 10:04:00Z | 2020-10-13 12:04:23.4098165 +02:00 | Free |
| 2 | 2020-10-13 10:04:22Z | 2020-10-13 15:04:40.0415468 +02:00 | Occupied |
| 3 | 2020-10-13 13:04:31Z | 2020-10-13 18:40:10.8539946 +02:00 | Occupied |
| 1 | 2020-10-13 16:40:08Z | 2020-10-13 18:45:58.7620901 +02:00 | Free |
| 1 | 2020-10-13 16:45:57Z | 2020-10-13 18:49:01.7630668 +02:00 | Occupied |