Counting the number of people working at a given time

自古美人都是妖i 提交于 2020-01-06 06:36:51

问题


I have data the shows when employees log in and when they log out. I call the duration they are logged in "Ready" time and the time they are logged off as "Not Ready" time. What I want to do is have a continuous, gradient timeline that shows how many people are in the ready state.

Some notes about the data:

  • The data has a start time and an end time. Each record is unique for the employee and the start time?
  • I unfortunately cannot post this data as it does not belong to me.

回答1:


Let's say that your data is something like this

employee    start_time  end_time
E1  7/7/2017  10:03:10 AM   7/7/2017  18:03:10 AM
E2  7/7/2017  10:10:10 AM   7/7/2017  18:03:10 AM
E3  7/7/2017  10:13:10 AM   7/7/2017  18:03:10 AM
E1  7/7/2017  11:03:10 AM   7/7/2017  19:03:10 AM
E2  7/7/2017  10:30:10 AM   7/7/2017  18:03:10 AM

In that case I would follow these steps:

  • Check if start_time & end_time columns are not in 'timestamp' format then right click it and go to 'Change data type' to select 'Date & Time'
  • Create a parameter Select_Report_DateTime. In parameter window select Data type = 'Date & Time'; Display format = 'Automatic'; Allowable values = 'All'
  • Right click this parameter and select 'Show parameter control'
  • Create calculated field default_date_time as #1/1/1900 12:00:00 AM#. If it's not in 'timestamp' format then right click it and go to 'Change data type' to select 'Date & Time'
  • Create calculated field Report_DateTime_formatted as

IF [Select_Report_DateTime] == [default_date_time] then now()
ELSE [Select_Report_DateTime]
END

  • Create a calculated field Users(inReadyState) as

IF (([Report_DateTime_formatted] >= [start_time]) & 
    ([Report_DateTime_formatted] < [end_time])) THEN "Yes"
ELSE "No"
END

  • Now drag Users(inReadyState) in 'Columns', CNT[employee] in 'Rows' and 'Marks' as Bar.
  • You can very well play around with this model to get the o/p as per your specific requirement.

Don't forget to let us know if it helped :)



来源:https://stackoverflow.com/questions/44637703/counting-the-number-of-people-working-at-a-given-time

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!