Forum Discussion
calculating daily occupany rate
Hi
I am trying to find away to calculate the number of occupied spaces for a given day by parking area. For example, based on the arrival and departure dates how many customers have an occupied parking spot on a given day. And then to be able to drill down to view the chart/table by parking area.
az38 What i want to be able to see is by date the occupied spaces and to be able to drill into zone as below. And to have the total displayed. Thanking you in advance
The table below shows the correct values for zone, but not for left, right. The measure used for this is:
Measure 5 = CALCULATE(COUNTROWS(bookings), FILTER(ALL(bookings), bookings[adate]<=SELECTEDVALUE(CalendarAreasTable[Date]) && bookings[ddate]>=SELECTEDVALUE(CalendarAreasTable[Date]) && bookings[car park area]=SELECTEDVALUE(CalendarAreasTable[car park area])) )If I use measure 8, I get the correct values for car park (left/right) but there is no value displayed for zone.
Measure 8 = CALCULATE(COUNTROWS(bookings), FILTER(ALL(bookings), bookings[adate]<=SELECTEDVALUE(CalendarAreasTable[Date]) && bookings[ddate]>=SELECTEDVALUE(CalendarAreasTable[Date]) && bookings[car park area]=SELECTEDVALUE(CalendarAreasTable[car park area]) && bookings[car park]=SELECTEDVALUE(CalendarAreasTable[car park]) ) )
18 Replies
- az38
Community Champion
Hi ninakarsa
Your question is very complex and, obviously, there is not enough source data to give you a full and complex answer. but i try
first, the best practice is to create Calendar table for your task.
you could do this by create a calculated table like this
CalendarTable = CALENDARAUTO()or
CalendarTable = CALENDAR (DATE (2019, 1, 1), DATE (2019, 12, 31))next, you can create a dimension table 'Parking Areas' which define all reported areas (one area = one row in the table).
next, you can create a table CalendarAreasTable that will be looked like
Date Parking Area 01.01.2019 Zone A 01.01.2019 Zone B 01.01.2019 Zone C 02.01.2019 Zone A 02.01.2019 Zone B 02.01.2019 Zone C 03.01.2019 Zone A 03.01.2019 Zone B 03.01.2019 Zone C to do that create a new calculated table
CalendarAreasTable = CROSSJOIN(CalendarTable;'Parking Areas')next you can add a simple measure to your new CalendarAreasTable:
Measure = CALCULATE(COUNTROWS('DataTable'), FILTER(ALL('DataTable'), 'DataTable'[Departure Date]<=SELECTEDVALUE('CalendarAreasTable'[Date]) && 'DataTable'[Departure Date]>=SELECTEDVALUE('CalendarAreasTable'[Date]) && 'DataTable'[Parking Area]=SELECTEDVALUE('CalendarAreasTable'[Parking Area])) )where 'DataTable' is a table with log of your parking records
So, this measure will give you quantity of customers for each day by each Area and you could drill down it easily
do not hesitate to give a kudo to useful posts and mark solutions as solution
- ninakarsa
Helper II
Thanks for your quick response, so I will attached below the tables I have and what i want to do:
So Table A has the booking information, table b has the info that i want to drill by and table c is the calender
Table A: Bookings
Customer ID adate ddate car park car park area 123 01/05/2019 05/05/2019 Left Zone A 124 02/05/2019 04/05/2019 right Zone B 125 03/05/2019 05/05/2019 Left Zone C 126 04/05/2019 06/05/2019 right Zone A 127 01/05/2019 03/05/2019 Left Zone B 128 02/05/2019 04/05/2019 Left Zone C 129 03/05/2019 05/05/2019 Left Zone A 130 01/05/2019 03/05/2019 Left Zone B 131 02/05/2019 04/05/2019 Left Zone C 132 03/05/2019 05/05/2019 Left Zone A 133 01/05/2019 03/05/2019 Left Zone B 134 02/05/2019 04/05/2019 Left Zone A 135 03/05/2019 05/05/2019 right Zone B 136 05/05/2019 07/05/2019 right Zone C 137 06/05/2019 08/05/2019 right Zone A 138 04/05/2019 06/05/2019 right Zone A 139 05/05/2019 07/05/2019 left Zone B 140 06/05/2019 08/05/2019 left Zone C 141 08/05/2019 10/05/2019 left Zone A 142 09/05/2019 11/05/2019 left Zone B 143 07/05/2019 09/05/2019 left Zone C 144 08/05/2019 10/05/2019 left Zone A 145 09/05/2019 11/05/2019 left Zone B 146 11/05/2019 13/05/2019 left Zone C 147 12/05/2019 14/05/2019 left Zone A 148 10/05/2019 12/05/2019 left Zone B 149 11/05/2019 13/05/2019 left Zone A 150 12/05/2019 14/05/2019 left Zone B Table B: Info
car park car park area Left Zone A right Zone B Zone C Table C: Calendar
Table 😧
crossjoin(calendar,Info)
Then I use the following calcuation to give me the number of occupied spaces on a given day: but this is not returning any results
Measure =CALCULATE(COUNTROWS(bookings),FILTER(ALL(bookings), bookings[adate]>=SELECTEDVALUE(CalendarAreasTable[Date]) && bookings[ddate]<=SELECTEDVALUE(CalendarAreasTable[Date]) && bookings[car park area]=SELECTEDVALUE(CalendarAreasTable[car park area])))- az38
Community Champion
hi ninakarsa
it seems you're confused marks < and >
try
Measure = CALCULATE(COUNTROWS(bookings), FILTER(ALL(bookings), bookings[adate]<=SELECTEDVALUE(CalendarAreasTable[Date]) && bookings[ddate]>=SELECTEDVALUE(CalendarAreasTable[Date]) && bookings[car park area]=SELECTEDVALUE(CalendarAreasTable[car park area])) )do not hesitate to give a kudo to useful posts and mark solutions as solution