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
Anonymous
Not applicable

Power BI: Find out occupancy using Date Filter(Slicer)

I have a scenario where I want to find the occupancy by selecting a date in a slicer

 

 

Details are as below

 

Room Table: Room Id and Room name

Room ID Room Name
1R101
2R102
3R103
4R104
5R105

 

Occupancy Details Table: Contains the historical data for each room and for the period for which it was occupied.

 

Room IDCoustomer IDRoom NameStart Date End Date
11R101Jan-17Mar-17
12R101Apr-17Jun-17
13R101Jul-17Sep-17
24R102Mar-17Jun-17
35R103Jan-17Sep-17
46R104Apr-17Dec-17
57R105Jan-17Jun-17

 

 

Now i want to pass a data and find out which rooms were occupied and vacant on a particular date.

 

Eg If I pass date as Jul-2017

I will get R101, R103 and R104 as Occupied rooms.

 

However, While calculating the Vacant Rooms historical records of R101 are also considered.

I want a workaround by which I could exclude the historical records of all the currently occupied Rooms.

 

Desired output

 

Date Filter - Jul 2017

Occupied Rooms: R101, R103, and R104

Vacant Rooms: R102 and R105

 

Please let me know if you need further details and looking forward to your feedback.

 

Thanks,

2 ACCEPTED SOLUTIONS
v-sihou-msft
Employee
Employee

@Anonymous

 

In this scenario, you need to create a full calendar table. And don't create relationship between Calendar table and this Book table. 

 

Then create a flag measure to determine if the room is available.

 

IsAvailable = IF( MAX('Calendar'[Date]) >=MAX(Book[Start Date ]) && MAX('Calendar'[Date]) <=MAX(Book[End Date] ),0,1)

Then add this measure in to Visual Level Filter.

 

5.PNG

 

Regards,

View solution in original post

@Anonymous

 

The Tree Map should only accept hierarchical data in Group or Detail, which means the values should be "fixed". You can't put a measure. You may try to add measure into Value or Tooltip.

 

Regards,

View solution in original post

4 REPLIES 4
v-sihou-msft
Employee
Employee

@Anonymous

 

In this scenario, you need to create a full calendar table. And don't create relationship between Calendar table and this Book table. 

 

Then create a flag measure to determine if the room is available.

 

IsAvailable = IF( MAX('Calendar'[Date]) >=MAX(Book[Start Date ]) && MAX('Calendar'[Date]) <=MAX(Book[End Date] ),0,1)

Then add this measure in to Visual Level Filter.

 

5.PNG

 

Regards,

Anonymous
Not applicable

@v-sihou-msft

 

Thanks, Using the flag to identify the occupancy of the room had resolved my problem.

I have a one follow-up question.

 

I have created a calculated measure as you have suggested 
IsAvailable = IF( MAX('Calendar'[Date]) >=MAX(Book[Start Date ]) && MAX('Calendar'[Date]) <=MAX(Book[End Date] ),0,1)

 

Then I have used this calculated measure as below

 

Occupant = CALCULATE( If( [IsAvailable]=1 , MAX([Tenant Name]) , MAX([Room Name])))

 

This Measure displays "Tenant Name" if it is occupied else it will display "Room Name".

 

This measure works correctly in matrix visuals. However, I am not allowed to use this measure (Occupant)in Treemap as group or

detail values. 

 

 

Capture.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Is this a limitation of Treemap or am I missing something?


Thanks

@Anonymous

 

The Tree Map should only accept hierarchical data in Group or Detail, which means the values should be "fixed". You can't put a measure. You may try to add measure into Value or Tooltip.

 

Regards,

Anonymous
Not applicable

@v-sihou-msft

 

It works with Tooltip, not in values (I guess the reason being that measure return text values ), I will try Visio visual to achieve this functionality of highlighting floor/room occupancy.

Thanks for the quick feedback.

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.