跳到主要内容

如何计算数据透视表中的唯一值?

默认情况下,当我们基于包含一些重复值的数据范围创建数据透视表时,也会对所有记录进行计数,但是有时,我们只想基于一列对唯一值进行计数以获得正确的值屏幕截图结果。 在本文中,我将讨论如何计算数据透视表中的唯一值。

使用帮助程序列在数据透视表中计算唯一值

使用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 Tab 为 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