300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > python数据透视表计数去除重复_excel透视表计数去重_Excel数据透视表中的唯一计数...

python数据透视表计数去除重复_excel透视表计数去重_Excel数据透视表中的唯一计数...

时间:2020-01-08 10:09:41

相关推荐

python数据透视表计数去除重复_excel透视表计数去重_Excel数据透视表中的唯一计数...

In a previous article, Roger Govier showed us a couple of different ways to get a Unique count with a Pivot Table.

在上一篇文章中,Roger Govier向我们展示了几种不同的方法来通过数据透视表获得唯一计数 。

Create a Pivot of a Pivot Tables results (fast)

创建数据透视表的数据透视(快速)

Add a calculated column to the source data (much slower)

将计算出的列添加到源数据(慢得多)

Now Roger has added another technique that you can use, in Excel and later. I'll hand things over to Roger, so he can describe the steps.

现在,Roger在Excel 及更高版本中添加了另一种可以使用的技术。 我将事情交给罗杰,以便他描述步骤。

添加到数据模型 (Add to Data Model)

With the advances made by Microsoft with Power Pivot, and DAX (Data Expressions) formulae, which are more powerful than the inbuilt Excel functions, there is a way of obtaining a Distinct Count. From Excel onward, when creating a Pivot Table form any set of data, there is an option to Add this data to Data Model.

随着Microsoft在Power Pivot和DAX(数据表达式)公式方面所取得的进步,它们比内置的Excel函数更强大,因此有一种获取非重复计数的方法。 从Excel 开始 , 从数据集创建数据透视表时,可以选择将数据添加到数据模型。

When you select this option, Excel treats the data as being loaded into Power Pivot, as opposed into the older Pivot Table.

选择此选项后,Excel会将数据视为已加载到Power Pivot中,而不是旧数据透视表中。

我的默认选择 (My Default Choice)

Even though you might not want to be combining data from multiple tables and creating relationships between tables, this is now my default choice when I create a Pivot Table.

即使您可能不想合并多个表中的数据并在表之间创建关系,现在这也是我创建数据透视表时的默认选择。

Then, when creating the PT, and dragging an item to the Values area, when you click on Value Field settings, and scroll to the bottom, there is a new measure that has been added called Distinct Count.

然后,在创建PT并将项目拖到“值”区域时,单击“值字段”设置并滚动到底部,将添加一个名为“非重复计数”的新度量。

看到不同的计数 (See a Distinct Count)

Choosing this Measure, as opposed to Count, does indeed give you a unique count as can be seen in the following PT example.

与Count相反,选择此度量确实可以为您提供唯一的计数,如下面的PT示例所示。

For each Salesperson, I allocated Product to the Values area twice, once as Count and once as Distinct Count, and I did the same for Customers.

对于每个销售人员,我将产品两次分配到“值”区域,一次分配为“计数”,一次分配为“非重复计数”,而我对“客户”也执行相同的操作。

NOTE: Distinct Count of Product is a measure you wouldn't need, as it clearly has to be the same as the number of Products sold, 5. It has only been included for illustrative purposes.

注意:“产品的不同数量”是您不需要的度量,因为它显然必须与所售产品的数量相同。5.仅出于说明目的将其包括在内。

项数 (Count of Items)

As you can see the Count of Product is the same as the Count of Customer, which is not at all surprising as it is the count of all of the transactions made by these particular Salespeople.

如您所见,产品数量与客户数量相同,这并不奇怪,因为它是这些特定销售人员进行的所有交易的数量。

(The image is trimmed below, to show Barry's Count of Product and Count of Customer, at a larger font size.)

(下面的图像进行了裁剪,以较大的字体显示Barry的产品数和客户数。)

客户的不同数量 (Distinct Count of Customer)

But, the Distinct Count of Customer shows that even though there were 41, 42 and 27 transactions by the three Salespeople shown, they made those sales to 11, 12 and 13 Unique Customers in each case, showing there have been multiple sales to the same Customer.

但是,“不同客户数量”显示,即使显示的三个销售人员分别进行了41、42和27个交易,但他们在每种情况下都分别向11、12和13个唯一客户进行了销售,表明同一笔交易有多个顾客。

(The image is trimmed below, to show Barry's Count of Customer and Distinct Count of Customer, at a larger font size.)

(下面的图像进行了裁剪,以较大的字体显示Barry的客户数和客户的不同数。)

使用此方法 (Use This Method)

This is a much easier method than those I have shown in earlier articles, so if you have Excel or , or Office 365, then this is definitely the way to go. So, even if you don't need all of the other advantages of Power Pivot, it is always worth choosing the option to add data to the Data Model for all of the new Pivot Tables that you create.

与我之前的文章中介绍的方法相比,这是一种简单得多的方法,因此,如果您拥有Excel 或或Office 365,则绝对是一种方法。 因此,即使您不需要Power Pivot的所有其他优点,也始终值得选择为您创建的所有新数据透视表向数据模型添加数据的选项。

Big thanks to Microsoft for introducing this long awaited feature, and for making it so easy for people to use without having to get into learning DAX (although there are many benefits from doing so).

非常感谢Microsoft引入了这一期待已久的功能,并使其易于使用,而无需学习DAX(尽管这样做有很多好处)。

获取样本文件 (Get the Sample File)

Thanks to Roger, for explaining how we can easily get a distinct count now! It's easy to overlook that "Add this data to the Data Model" check box, when creating a pivot table. Or, if you aren't aware of the benefits, you wouldn't bother to check it.

感谢罗杰(Roger),解释了我们现在如何轻松获得独特的计数! 创建数据透视表时,很容易忽略“将数据添加到数据模型”复选框。 或者,如果您不了解好处,则无需费心检查它。

If you'd like to download Roger's sample file, from his earlier tutorial, you can go to my Contextures website. Visit the different ways to get a Unique count page, and go to the Download the sample file section. You can use that data to create a new pivot table, and remember to check the "Add this data to the Data Model" box!

如果您想从Roger的较早教程中下载其示例文件,则可以转到我的Contextures网站。 访问获取“唯一计数”页面的不同方法 ,然后转到“下载示例文件”部分。 您可以使用该数据创建新的数据透视表,并记得选中“将此数据添加到数据模型”框!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。