簡體   English   中英

沒有重復,計算每天進入的人數

[英]Without duplication, count number of people entering each day

我正在使用如下工作表:

Date/Time      Badge       Name
10/31/2013    
8:01:02 AM     131078      YEO, Nita
8:03:17 AM     415416      PEH, Wei
10/30/2013    
8:11:02 AM     131098      LEE, Alice
8:53:17 AM     215416      EG, shi
...
  1. 我想計算一天內沒有重復輸入的人數。 只是日期,而不是確切的時間。 每個人都有一個獨特的徽章編號。

  2. 在那之后,我有另一張包含所有empoyees`徽章編號的工作表。 我想比較用這張表輸入的人員來排除訪客,即兩張床單內的人員仍然存在。 然后計算多少。

總而言之,在一個月內,計算每一天進入的訪客數量,而不是訪客數量。 並根據日期繪制數字。

如何使用excel,數據透視表或VBA完成此操作?

像這樣的東西

from collections import defaultdict

# collect all visitors in a dictionary where the key is the date, and
# the value is a set of badge numbers
visitorsPerDay = defaultdict(set)

# store the last read date value
currentDate = None

with open('filename') as f:
    for line in f:
        # if the line is 10 characters long, it’s a date line
        if len(line.strip()) == 10:
            # store the date value
            currentDate = line.strip()
        elif currentDate:
            # extract the badge number; if the file is tab
            # separated, even better: split by \t
            time, badge, _ = (part.strip() for part in line.split('   ', 2))

            # add the badge number to the set within the dictionary
            visitorsPerDay[currentDate].add(badge)

# now for every date, count the number of (unique) visitors
for date, visitors in visitorsPerDay.items():
    print(date, len(visitors))

在Excel中,在最左邊添加一列,假設'日期/時間'在B1中,在A2中輸入=IF(ISBLANK(C2),B2,A1)並向下復制以適應。 將ColumnA和Paste Special,Values復制到頂部。 過濾ColumnC(空白)並刪除所選行。 在A1中添加Date @Brett推薦,您的數據布局現在應該或多或少。


使用查找功能向每行添加是否訪問者的指示。

根據圖像左側的源數據指示構建的數據透視表將按天顯示唯一徽章訪問次數:

SO19764305的例子

過濾以僅在“報告過濾器”字段中選擇n ,並且僅具有員工的等效項。

對於每月數字,請使用組(在快速菜單上),按月,月份設施。

對於圖表,從行標簽中刪除徽章並插入合適的圖表。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM