跳到主要內容

如何計算數據透視表中的唯一值?

默認情況下,當我們基於包含一些重複值的數據范圍創建數據透視表時,也會對所有記錄進行計數,但是有時,我們只想基於一列對唯一值進行計數以獲得正確的值屏幕截圖結果。 在本文中,我將討論如何計算數據透視表中的唯一值。

使用幫助程序列在數據透視表中計算唯一值

使用Excel 2013和更高版本中的``值字段設置''對數據透視表中的唯一值進行計數


使用幫助程序列在數據透視表中計算唯一值

在Excel中,您需要創建一個幫助器列以標識唯一值,請執行以下步驟:

1。 在數據旁邊的新列中,請輸入此公式 =IF(SUMPRODUCT(($A$2:$A2=A2)*($B$2:$B2=B2))>1,0,1) 到單元格C2中,然後將填充手柄拖到要應用此公式的範圍單元格上,唯一值將被標識,如下面的屏幕截圖所示:

2。 現在,您可以創建數據透視表。 選擇包括幫助程序列的數據范圍,然後單擊 插入 > 數據透視表 > 數據透視表,請參見屏幕截圖:

3。 然後在 創建數據透視表 對話框中,選擇要在其中放置數據透視表的新工作表或現有工作表,請參見屏幕截圖:

4。 點擊 OK,然後拖動 課程 字段 行標籤 框,然後拖動 幫手  字段 價值觀 框,您將獲得以下數據透視表,該數據透視表僅計算唯一值。


使用Excel 2013和更高版本中的``值字段設置''對數據透視表中的唯一值進行計數

在Excel 2013及更高版本中, 區別計數 樞紐分析表中已新增函式功能,您可以套用此功能,以快速輕鬆地解決這項工作。

1。 選擇數據范圍,然後單擊 插入 > 數據透視表創建數據透視表 對話框中,選擇要在其中放置數據透視表的新工作表或現有工作表,然後選中 將此數據添加到數據模型 複選框,請參見屏幕截圖:

2。 然後在 數據透視表字段 窗格,將 課程 領域 框,然後拖動 姓名 領域 價值觀 框,請參見屏幕截圖:

3. 然後點擊 名稱計數 下拉列表,選擇 值字段設置,請參見屏幕截圖:

4。 在 值字段設置 對話框中單擊 匯總值 標籤,然後滾動以單擊 區別計數 選項,請參見屏幕截圖:

5。 然後點擊 OK,您將獲得僅計算唯一值的數據透視表。

  • 備註:如果您檢查 將此數據添加到數據模型 在選項 創建數據透視表 對話框, 計算字段 功能將被禁用。

更多有關數據透視表的文章:

  • 將相同的篩選器應用於多個數據透視表
  • 有時,您可能基於同一數據源創建多個數據透視表,現在您過濾一個數據透視表,並希望也以相同的方式過濾其他數據透視表,這意味著您想一次更改多個數據透視表過濾器。 Excel。 本文,我將討論Excel 2010和更高版本中新功能Slicer的用法。
  • 在Excel中更新數據透視表範圍
  • 在Excel中,當您刪除或添加數據范圍內的行或列時,相對數據透視表不會同時更新。 現在,本教程將告訴您數據表的行或列更改時如何更新數據透視表。
  • 在Excel中的數據透視表中隱藏空白行
  • 眾所周知,數據透視表方便我們在Excel中分析數據,但有時行中會出現一些空白內容,如屏幕截圖所示。 現在,我將告訴您如何在Excel的數據透視表中隱藏這些空白行。

最佳辦公生產力工具

🤖 Kutools 人工智慧助手:基於以下內容徹底改變數據分析: 智慧執行   |  生成代碼  |  建立自訂公式  |  分析數據並產生圖表  |  呼叫 Kutools 函數...
熱門特色: 尋找、突出顯示或識別重複項   |  刪除空白行   |  合併列或儲存格而不遺失數據   |   沒有公式的回合 ...
超級查詢: 多條件VLookup    多值VLookup  |   跨多個工作表的 VLookup   |   模糊查詢 ....
高級下拉列表: 快速建立下拉列表   |  依賴下拉列表   |  多選下拉列表 ....
欄目經理: 新增特定數量的列  |  移動列  |  切換隱藏列的可見性狀態  |  比較範圍和列 ...
特色功能: 網格焦點   |  設計圖   |   大方程式酒吧    工作簿和工作表管理器   |  資源庫 (自動文字)   |  日期選擇器   |  合併工作表   |  加密/解密單元格    按清單發送電子郵件   |  超級濾鏡   |   特殊過濾器 (過濾粗體/斜體/刪除線...)...
前 15 個工具集12 文本 工具 (添加文本, 刪除字符,...)   |   50+ 圖表 類型 (甘特圖,...)   |   40+ 實用 公式 (根據生日計算年齡,...)   |   19 插入 工具 (插入二維碼, 從路徑插入圖片,...)   |   12 轉化 工具 (數字到單詞, 貨幣兌換,...)   |   7 合併與拆分 工具 (高級合併行, 分裂細胞,...)   |   ... 和更多

使用 Kutools for Excel 增強您的 Excel 技能,體驗前所未有的效率。 Kutools for Excel 提供了 300 多種進階功能來提高生產力並節省時間。  點擊此處獲取您最需要的功能...

產品描述


Office選項卡為Office帶來了選項卡式界面,使您的工作更加輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 將您的工作效率提高 50%,每天為您減少數百次鼠標點擊!
Comments (28)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Thanks ! Saved me a lot of hours, me and my friend !
This comment was minimized by the moderator on the site
My Excel dont have check box " Add this data to the Data Model"
So, What can i do?
This comment was minimized by the moderator on the site
It supports only . xlsx
I have faced with the same problem. Nodody mention this. Everyone talk about MS Excel, and nobody about file)))
This comment was minimized by the moderator on the site
Hello, Jay,
Which Excel version do you use? This option is only added for Excl 2013 and later versions. If you do not find this option, please apply the first method in this article.
https://www.extendoffice.com/documents/excel/2127-excel-pivot-table-count-unique-values.html#a1

Thank you!
This comment was minimized by the moderator on the site
Thank you so much !!!!!
This comment was minimized by the moderator on the site
I cannot edit after I save. Can yo tell me why?
This comment was minimized by the moderator on the site
sorry, this still doesn't provide a solution for me in excel 2010. You're =if(sumproduct() formula doesn't work. It misses the values for the if formula if you use it like you put it and it doesn't count unique values in my excel sheet if I add =if(>1,01;1;0)...
This comment was minimized by the moderator on the site
oh man... you saved me so so so much time !!!
thanks a lot !!!!
This comment was minimized by the moderator on the site
Distinct count Option not shown in summarize value by - Excel version 2013
This comment was minimized by the moderator on the site
Please verify that you have ticked the "Add this data to data model" check in the CreatePivot dialog box :)
This comment was minimized by the moderator on the site
I faced the same issue and then found the resolution.
Seems that it's available only when you tick the "Add this data to the Data Model" checkbox in the Create PivotTable dialog box.
Please try if that helps
This comment was minimized by the moderator on the site
same for me! Any suggestion?
This comment was minimized by the moderator on the site
These all work but only to an extent. I'm trying to find a solution for the issue with all of these. When I create a helper column and use the formula =IF(SUMPRODUCT(($A$2:$A2=A2)*($B$2:$B2=B2))>1,0,1) I do indeed get the distinct count. But how do you resolve the issue were you need the pivot fields to include one of the lines of data where the formula gives a zero? I also tried using the Data Model and distinct count. This gives the correct count but when you double click the data to drill down you do not get the data specified in the pivot.
This comment was minimized by the moderator on the site
Amazing! thanks a tons - this worked for me on Excel 2016.
This comment was minimized by the moderator on the site
I don't see the Distinct Count under Summarize Value By tab. My "Add this data to the Data model" check box is also grey out. How can I change this setting?
This comment was minimized by the moderator on the site
Ran into the same issue... it is probably because the file you opened was as a csv. When I reopened my file as an excel file (either start a new one, copy+paste or save as), I have the functionality of adding to data model
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations