0

I am trying to plot data in a bar-chart. On the x-axis I want to display the answer category (1-9) and on the y-axis the amount of times it has been chosen. Not every category has been selected, which results in the following pivot table:

        Column Labels                       
        1   4   5   6   7   8   Grand Total
Count   2   12  90  48  56  8   216

When I plot this data, I get the following figure:

The problem is, the pivot table ignores the distance between two categories. In other words, the graph ignores the fact that there are supposed to be a 2, 3, and 9 (with count = 0) on the X-axis.

How can I get the pivot chart to add the missing categories, without sacrificing the versatility of the Pivot-chart and table?

Raw data

I simply organized the data in a column of a table. In that column (workload), a value can occurs once, multiple times, or not at all. I did find a non-pivot-table solution in which I simply used Countif.

Department   Workload     ...    Col_n
2            5            ...
3            5
2            7
1            1
2            6
1            4
...          ...
4

1 回答 1

1

这是一个很好的问题,要正确地回答它,需要访问您的原始数据(枢轴将它们带到哪里)。但是,我会给您一个一般情况,我认为您可以对其进行一些更改以满足您的需要。

数据透视表的问题在于您不能使用它们来报告不存在的数据。因此,您可以通过添加缺失数据来解决此问题。

所以第一步是在数据中添加一些虚拟记录。您可以为每个缺少的类别添加一个虚拟记录。

现在,当刷新数据透视表时,应该会出现缺失的类别,但计数中的单元格为空白。这与我们想要的很接近,但最好在此处显示零。

我们应该给数据透视表一些东西来计算,这样你就可以添加“X”或“-”。

通过该更改,ID 列中会显示一个数字,但我们希望该数字为 0,而不是 1。

现在您应该更改摘要函数

工作表函数包括 COUNTA,它计算一个区域中的所有非空白单元格,以及 COUNT,它只计算带有数字的单元格。数据透视表中有类似的功能,但令人困惑,因为数据透视表 COUNT 就像工作表 COUNTA 一样,也计算文本。

您可以将汇总函数更改为仅计算数字的函数,而不是使用计数。然后,您计算的列中的那些字符将不被计算在内。

在此处输入图像描述

要更改摘要功能:

  1. 在数据透视表的计数列中选择一个单元格。
  2. 在功能区的数据透视表工具下,单击选项选项卡
  3. 在活动字段组中,单击字段设置

在 Value Field Settings 对话框中,在函数列表中,单击 Count Numbers,然后单击 OK

在此处输入图像描述

数据透视表现在为缺少数据的类别显示零,而不是空白单元格或不正确的计数。

于 2017-05-03T12:16:26.497 回答