简体   繁体   English

单个数据透视表中带有过滤器的多个计算列

[英]Multiple Calculated Columns with Filters within Single Pivot Table

I am working to create a Pivot Table in Excel that has multiple calculated fields that take into account whether a condition is true, but cannot figure out how to create this within a single Pivot Table. 我正在努力在Excel中创建数据透视表,该数据透视表考虑了条件是否为真,但具有多个计算字段,但无法弄清楚如何在单个数据透视表中创建该数据透视表。

Behind the scenes, I have a set of data with a column that can have these values: A,B,C,D,F,L, or R. I have another column that is a dollar value, and another for Quantity. 在幕后,我有一组数据,这些数据的列可以具有以下值:A,B,C,D,F,L或R。我有另一列是美元值,另一列是数量。 I am trying to calculate the price per unit when the Category is A,B, or C, but also calculate the price per unit when the Category is D. 我正在尝试计算类别为A,B或C时的每单位价格,但也试图计算类别为D时的每单位价格。

I can create multiple Pivot Tables and tie them to the same slicer, but the issue is this: I need to display the spending in each of the two categories for each location, and when I create two separate Pivot Tables for this, locations that do not have spending in one of the categories are excluded (in this below case, location 2 has no spending in Category D, so it does not show up in the second Pivot Table). 我可以创建多个数据透视表并将它们绑定到同一个切片器,但是问题是这样的:我需要针对每个位置显示两个类别中每个类别的支出,并且当我为此创建两个单独的数据透视表时,类别之一中没有支出的情况将被排除(在这种情况下,位置2在类别D中没有支出,因此它不会显示在第二个数据透视表中)。

Here is a portion of my data set. 这是我的数据集的一部分。 The whole data set is over 100,000 rows and will change over time, so I do need a solution for the long-term. 整个数据集超过100,000行,并且会随着时间而变化,因此我确实需要长期解决方案。

Location Category Volume Quantity

1 A $120.32 6000

3 A $30.08 1300

3 A $60.16 2600

1 B $39.91 1000

2 B $318.50 13000

2 C $196.00 8000

1 D $220.50 8100

3 D $171.50 6300

3 D $35.90 1000

3 D $53.85 1500

2 F $416.50 0

1 L $24.50 0

2 L $30.08 0

1 R $55.13 0

2 R $55.13 0

3 R $110.26 0

Thanks in advance for your help and let me know if I need to clarify anything! 预先感谢您的帮助,如果需要澄清,请告诉我!

Alright, a little more digging yielded the answer. 好吧,多一点挖掘就得出了答案。 A slicer should be included that has all locations selected, then it should be tied to all Pivot Tables in use. 应该包括一个已选择所有位置的切片器,然后将其与使用中的所有数据透视表绑定。 For all Pivot Tables, go to Field Settings, then click on the Layout and Print Tab. 对于所有数据透视表,请转到“字段设置”,然后单击“布局和打印”选项卡。 Check the box 'Show items with no data'. 选中“显示无数据的项目”框。 Then go to Pivot Table Options and select the values you would like to display for blanks and errors. 然后转到“数据透视表选项”,然后选择要显示的空白和错误值。

I found the solution here . 我在这里找到了解决方案。

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

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