vba 使用值创建计算字段以在 excel 数据透视表中创建切片器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22008442/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 02:07:09  来源:igfitidea点击:

Create a calculated field using values to create a slicer in excel pivot table

excelexcel-vbapivot-tableslicecalculated-fieldvba

提问by silvster27

I have a data set where one column (job type) has 4 values in it (A,B,C,D). I am using that column as a slicer in a pivot table. However I would like to modify this slicer to only have two options (X,Y) where X=A+B and Y=C+D. I know I could create a new column in the raw data but I am trying to avoid this as the raw data source is already highly manipulated through several dozen high complexity mods.

我有一个数据集,其中一列(作业类型)中有 4 个值(A、B、C、D)。我将该列用作数据透视表中的切片器。但是我想修改这个切片器只有两个选项(X,Y),其中 X=A+B 和 Y=C+D。我知道我可以在原始数据中创建一个新列,但我试图避免这种情况,因为原始数据源已经通过几十个高复杂性的 mod 进行了高度操纵。

回答by Ken

Apologies if this isn't clear!

如果不清楚,请见谅!

This is tested on Excel 2010.

这是在 Excel 2010 上测试的。

I'm assuming that you have your pivot table setup with the items you want to slice as the row labels.

我假设您已将数据透视表设置为要切片的项目作为行标签。

Select the "A" label, ctrl click the "B" label, and then right click, selecting "Group". Do the same thing for the "C" and "D" entries. You will notice a new field in the Field List and in the Row Labels section.

选择“A”标签,ctrl单击“B”标签,然后右键单击,选择“组”。对“C”和“D”条目执行相同的操作。您会注意到字段列表和行标签部分中有一个新字段。

Clean up by changing the name of the new label, and the new groups.

通过更改新标签和新组的名称进行清理。

Drag it out of the Row Labels area. Your pivot table should look like it did before, but with a new field available. Insert a slicer, using that field as the selection field.

将其拖出“行标签”区域。您的数据透视表应该看起来像以前一样,但有一个可用的新字段。插入一个切片器,使用该字段作为选择字段。

Have a look at a quick video I made here: http://youtu.be/QIcZPGxisKM

看看我在这里制作的快速视频:http: //youtu.be/QIcZPGxisKM