Forum Discussion

mpmsltd's avatar
mpmsltd
Helper I
6 years ago
Solved

Daily Occupancy Average

Hi everybody,

 

I have a table that shows the Start Date, End Date and Customer ID. What I want to do is to see the daily occupancy average per period of time (year for example and be able to drill down to a month). Another requirement is the ability to see on each day how many occupants there were exactly (not sure if that would be on a different visual). 

For example:

for 11/07/2018- I would have everybody that started on this date minus people that left on this day plus people that have arrived earlier but either checked out later or haven't checked out yet (end date = blank).

This is pretty much a sample of what I have where num is the customer ID. Like I mentioned before the blank end date should be considered as not ended yet.

Can somebody please help me out? Thank you so much in advance!

 

numstart dateend date
70012/17/20158/11/2016 8:18
109612/31/201512/31/2015 21:27
109512/30/201512/30/2015 16:59
92012/15/201512/15/2015 15:31
108012/14/201512/14/2015 4:39
107712/9/201512/9/2015 13:21
107812/9/201512/9/2015 2:52
9048/26/20158/26/2015 12:01
89712/6/201512/6/2015 4:44
107412/2/201512/2/2015 3:08

19 Replies

  • v-frfei-msft's avatar
    v-frfei-msft
    Community Support

    Hi mpmsltd ,

     

    Please check the following steps as below:

    1. Create the inactive  relationship between tables as below.

     

    2. Then we can create measures as below to work it out.

    Measure = 
    VAR mind =
        MIN ( 'date'[Date] )
    VAR mad =
        MAX ( 'date'[Date] )
    VAR a =
        CALCULATE (
            COUNTROWS ( 'Table' ),
            FILTER (
                ALL ( 'Table' ),
                mind >= 'Table'[start date]
                    && OR ( 'Table'[end date] >= mad, 'Table'[end date] = BLANK () )
            )
        )
    RETURN
        a
    
    Measure 2 = 
    VAR d =
        MAX ( 'date'[Date] )
    VAR a =
        CALCULATE (
            COUNTROWS ( 'Table' ),
            USERELATIONSHIP ( 'date'[Date], 'Table'[start date] )
        )
    VAR b =
        CALCULATE (
            COUNTROWS ( 'Table' ),
            USERELATIONSHIP ( 'date'[Date], 'Table'[end date] )
        )
    VAR c =
        CALCULATE (
            COUNTROWS ( 'Table' ),
            FILTER (
                'Table',
                'Table'[start date] > d
                    && OR ( 'Table'[end date] = BLANK (), 'Table'[end date] > d )
            )
        )
    RETURN
        a - b + c
    

     

     

    For more details, please check the pbix as attached.

     

    • mpmsltd's avatar
      mpmsltd
      Helper I

      Hi v-frfei-msft thank you so much for your help.

      But the totals are off, please check the file attached. For example the total for January 2017 is showing 586 but then all the days have more than 700 people. Can you please check it again? Also how can I attach my pbix file in here?

       THanks!

    • mpmsltd's avatar
      mpmsltd
      Helper I

      Thanks Ashish_Mathur  but this is not what I need. 

       

      What I need is the daily occupancy average - which is a calculation of: customers that were staying on that day + customers that arrived on that day - customers that left on that day

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hello All,

     

    Thanks for your replies. Ashish_Mathur ´s solution has helped us a lot. 

     

    Now, we want to take it to the next level and evaluate this measure for a MONTH scale or even within a YEARLY basis. 

     

    This is not being possible since the total OCCUPIED ROOMS are not a sum of the occupied rooms for every night. I believe this was also the case for posted solution, since the total does not match up with the correct sum for the period of nights shown. 

     

    Any ideas how we can manage this? 

     

    In case you need to see toher tables from our model, let me know. 

     

    Thanks in advance!!

    Santiago Sanchez 

     

     

    P.S: In our model, every reservation code has a defined number of occupied rooms (the values are calculated also using a TABLE created within POWERQUERY ). 

    • Ashish_Mathur's avatar
      Ashish_Mathur
      Super User

      Hi,

      Share the link from where i can download your PBI file and show the expected result.

      • Anonymous's avatar
        Anonymous
        Not applicable

        First of all, thank you all for helping us. 

         

        THis is the link where you can download the pbix. file:

        https://1drv.ms/u/s!AtEu70FghQZohcZeLVDKCRAsVeh3Xg?e=WbXSad  

         

        Now, there you will see my comments and the expected results there. 

         

        We are having trouble since the total values for the measure is not computing the sum of rooms occupied per night. So no clue on getting a monthly avarage occupancy rate...

         

        Thanks so much. 

         

        Santiago Sanchez