Tableau:当维度在行中时,如何计算一个值占另一个值的百分比

Tableau: How do I calculate the proportion of one value as a percentage of another value, when the dimensions are in the rows

首先我要说的是,我对 Tableau 还很陌生,而且我目前使用的是 9.1 版。

这是我的数据格式:

Date        Color   Fruit   Value
1/1/2016    Red     Apple   1
1/1/2016    Red     Apple   2
1/1/2016    Red     Pear    2
1/1/2016    Red     Pear    3
1/2/2016    Green   Apple   4
1/2/2016    Green   Apple   2
1/2/2016    Green   Pear    1
1/2/2016    Green   Pear    2

我如何计算苹果的总和占所有水果的百分比?红苹果占所有苹果的百分比如何?

请随时评论我如何清理这个问题,我知道它的状态很糟糕。谢谢

为了显示总计百分比,您应该右键单击您的度量并select快速Table计算 --> 总计百分比。

例子 将 Furit 拖到 Rows 上,然后拖到 Pane 上的 Value。 你应该得到:

Apple 9
Pear 8

现在您可以添加您的快速 table 计算,您将得到:

Apple 52,941%
Pear 47,059%

编辑第二个问题

拖动行架子中的颜色将更新所有百分比(占总数)。 如果您想按水果查看百分比,只需调整 table 计算的计算类型。 为此,您必须右键单击您的度量,然后单击 "Compute Using",然后单击 select 水果。