2 Replies Latest reply on May 20, 2015 11:59 AM by Nicole Bouchard

    Visitors at a Given Time

    kevin.foley

      I'm looking at visitor data with check in and check out time.  I was trying to find a way to plot the number of visitors at a given time.

       

      I'm fairly new to Tableau but the way I see it in SQL would be joining to a table of times with a count of visitors where time_of_day BETWEEN check_in_time AND check_out_time.  I feel like there may be a more straightforward or easy way to handle this in Tableau. 

       

      I've attached a workbook with sample data. Any help is appreciated.

        • 1. Re: Visitors at a Given Time
          Noah Salvaterra

          As I read it you'd want to know how many guests are present at all times, not just when someone is checking in or out. This makes this a bit of a tricky one as it involves creating data through densification. The structure of your data adds to this complexity, while I believe it could be done without reshaping, I went the easier route, which is to restructure things. I did this in excel, but if you are working from a dynamic datasource, this could be accomplished there pretty easily (let me know if you need help with that query).

           

          The structure I used has twice the rows, because each row is now a checkin or checkout event, rather than a guest. That way we can have a single time field, an event type and the guest id. Once in this form things become more straightforward. Either a continuous or a discrete date field can be used, however, in the discrete case the date granularity must be selected as a range aware type. That is basically everything except for exact date which allows "show missing values" to be selected for the date-time by right clicking the pill the view. I used a table calculation to carry the current occupancy from one step to the next (i.e. minute or second for example) incrementing based on checkin/checkout as needed the compute using for this calculation should be the date-time field.

           

          Let me know if this makes sense and does what you need, or if there are any particular points that are confusing. I'm happy to elaborate.

           

          N.

          • 2. Re: Visitors at a Given Time
            Nicole Bouchard

            I am looking for a similar solution. One solution I considered was making a table of all potential dates and bringing that in, but I feel like there must be a better way. Also working on a capacity/usage at a given time question.