简体   繁体   English

数据透视表中的总计和小计

[英]Totals and subtotals in pivot table

Pivot table data has the following structure: # Person A Quantity # ## Category X 10 ## ## Category Y 20 ## ## Category Z 25 ## # Person A Total 55 # # Person B # ## Category X 30 ## ## Category Y 15 ## ## Category Z 0 ## # Person B Total 45 # # Grand Total 100 # 数据透视表数据具有以下结构:#人员A数量###类别X 10 ## ##类别Y 20 ## ##类别Z 25 ###人员A总计55##人员B###类别X 30# ###类别Y 15 ## ##类别Z 0 ###人B总计45##总计100#

Is it possible to have Grand Total in the structure shown below: # Grand Total 100 # ## Category X 40 ## ## Category Y 35 ## ## Category Z 25 ## Just grand totals by the values of second labels in pivot table rows. 是否可以在下面所示的结构中包含总计:#总计100###类别X 40 ## ##类别Y 35 ## ##类别Z 25 ##仅通过枢轴中第二个标签的值得出总计表行。 在此处输入图片说明 Pic1 as it is now. 现在的Pic1。 在此处输入图片说明 Pic2 as required. Pic2根据需要。

I can get to this: 我可以做到这一点:

在此处输入图片说明

...by first turning this: ...首先将其旋转:

在此处输入图片说明

...into this: ...变成这样:

在此处输入图片说明

Which I then use for the Pivot Table: 然后将其用于数据透视表:

在此处输入图片说明

I chose for Subtotals to "Show all Subtotals at Top of Group" and turned Grand Totals "Off for Rows and Columns". 我选择小计为“在组顶部显示所有小计”,并将总计总计“关闭行和列”。

I used Power Query to make the new table that I used for the Pivot Table. 我使用Power Query制作了用于数据透视表的新表。 For that, I used the original table (Table1) as the source. 为此,我使用原始表(Table1)作为源。 Then I did Transform -> Group By, with these settings: 然后,我使用以下设置进行了Transform-> Group By:

在此处输入图片说明

Then I did Add Column -> Custom Colum, with these settings: 然后,我使用以下设置添加了列->自定义列:

在此处输入图片说明

Then I did Home -> Append Queries, with these settings: 然后,使用以下设置进行了“首页->追加查询”操作:

在此处输入图片说明

Then, in the formula bar, I changed this: 然后,在编辑栏中,我对此进行了更改:

在此处输入图片说明

...to this: ...对此:

在此处输入图片说明

#"Changed Type" points to the earlier Applied Query Step that was the last "version" of the original table. #“更改的类型”指向较早的“应用的查询步骤”,该步骤是原始表的最后一个“版本”。 This appends the most recent "version" (#"Added Custom") with it. 这将附加最新的“版本”(#“添加的自定义”)。 It appends the #"Added Custom" "query" to the #"Changed Type" "query". 它将#“ Added Custom”“查询”追加到#“ Changed Type”“查询”。

Then Home -> Close and Load to close Power Query and load the new table into a new tab in your spreadsheet. 然后依次单击首页->关闭并加载以关闭Power Query,并将新表加载到电子表格的新标签中。 That's the table to use for your Pivot Table. 这就是要用于数据透视表的表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM