cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

New Member

## Availability Table

Hello,

I'm creating a dashboard to display the future occupancy of a hotel's apartments, based on information from the reservations that have been made in the system. But I found myself in a problem that I still haven't found a solution. When I load the system data that are saved in the DB SQL SERVER, the table that has the reservation information returns the following data.

Each ID shown in the image above represents a reservation, then the arrival date and departure date and finally the number of adults and children that are in this reservation. To create this availability panel, I need to distribute the number of adults and children over the period they stayed, and on the day of departure these people cannot be counted. I'm using two reservations below for example.

On the 04/03th, 8 adults from the ID 5 reservation entered and 4 adults from the ID 6 reservation entered
On the 04/03th, 8 children from the ID 5 reservation entered and 3 children from the ID 6 reservation entered

Children = 8+3=11

Result of the day 04/03 - 12 Adults and 11 Children

On 05/04 - There was no entry and exit, so I will only count who is already staying

On 06/04 the ID 6 reservation came out so I have to subtract the amount of children and adults
Children = 11-3=8

Result of the day 06/03 - 8 Adults and 8 Children

On 06/04 the ID 5 reservation came out so I have to subtract the amount of children and adults

Children = 8-8=0

Result of the day 07/03 - 0 Adults and 0 Children

Is it possible to do this data modeling within BP?

1 ACCEPTED SOLUTION
Solution Specialist

Hello @wellington491. Something like the measures below should work.

I created a .pbix here in case it's helpful.

``````Adults =
VAR CurrentDate =
MAX ( Dates[Date] )
VAR Result =
CALCULATE (
Data[INPUT] <= CurrentDate
&& Data[OUTPUT] > CurrentDate
)
RETURN
Result``````
``````Children =
VAR CurrentDate =
MAX ( Dates[Date] )
VAR Result =
CALCULATE (
SUM ( Data[CHD] ),
Data[INPUT] <= CurrentDate
&& Data[OUTPUT] > CurrentDate
)
RETURN
Result``````

3 REPLIES 3
New Member

Hello @SteveHailey Thank you very much, it worked perfectly.

Taking advantage of the opportunity, can you kindly let me know how I can hide in the visual, the lines that already have past dates?

Once again, thank you very much for your attention.

Solution Specialist

You're welcome! I think the simplest way to hide rows that have past dates would be to select the table, and then in the filter pane add a Relative date filter; something like what is shown below:

It could also be done with DAX if you don't love the above method.

Solution Specialist

Hello @wellington491. Something like the measures below should work.

I created a .pbix here in case it's helpful.

``````Adults =
VAR CurrentDate =
MAX ( Dates[Date] )
VAR Result =
CALCULATE (
Data[INPUT] <= CurrentDate
&& Data[OUTPUT] > CurrentDate
)
RETURN
Result``````
``````Children =
VAR CurrentDate =
MAX ( Dates[Date] )
VAR Result =
CALCULATE (
SUM ( Data[CHD] ),
Data[INPUT] <= CurrentDate
&& Data[OUTPUT] > CurrentDate
)
RETURN
Result``````

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

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

#### Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors
Top Kudoed Authors