如何计算tableau public中子集的值和百分比的出现? [英] How to count occurrence of value and percentage of a subset in tableau public?

查看:2331
本文介绍了如何计算tableau public中子集的值和百分比的出现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组数据,格式如下:

  Q1 | Q2 
P1 | 4 | 5
P2 | 1 | 2
P3 | 4 | 3
P4 | 6 | 4

我想显示回答大于3的人数和百分比。所以在这种情况下,输出将是:

 计数|百分比
Q1 | 3 | 75%
Q2 | 2 | 50%

有任何建议吗?

解决方案

虽然听起来像一个相当容易的事情,它是一个更复杂。


  1. 将数据加载到Tableau中

  2. 在DataSource屏幕中,选择列Q1和Q1,右键单击它们并选择Pivot

  3. 将答案命名为Answers 。
    您应该得到一个如下所示的表:



现在您需要创建一个计算字段(我称之为 Overthreshold ,以检查您的条件:

  if [Answer]> 3 then 
[Answer]
End

此时,您可以用参数替换 3 改变那个条件
你可以按如下方式取药:



现在如果你想要的百分比,它得到一个更复杂,因为你必须确定问题的数量和答案的数量> 3,这是存储在两个不同的列的信息。


  1. 使用此计算创建另一个计算字段 COUNT([Overthreshold])/ AVG({fixed [Question]:count })

  2. 将创建的药片放在文本字段或列抽屉中,并查看百分比值

  3. 右键点击字段,然后选择默认属性/数字格式将其设置为百分比而不是浮点型



要解释什么是公式:
它需要超过阈值的答案计数,每个问题的答案数。这是通过 fixed 部分计算 Question 列中具有相同值的行来完成的。 AVG 只在那里,因为Tableau需要在那里聚集。由于对于问题的每个记录的值都是相同的,因此也可以使用 MIN MAX p>

感觉应该有一个更简单的解决方案,但现在我不能想到一个。


I have a set of data in the following format:

Resp | Q1 | Q2
P1   | 4  | 5
P2   | 1  | 2
P3   | 4  | 3
P4   | 6  | 4

I'd like to show the count and % of people who gave an answer greater than 3. So in this case, the output would be:

Question | Count  | Percent
Q1       |  3     | 75%
Q2       |  2     | 50%

Any suggestions?

解决方案

Although it sounds like a fairly easy thing, it is a bit more complicated. Firstly your data is not row based so you will have to pivot it.

  1. Load your data into Tableau
  2. In the DataSource Screen choose column Q1 and Q1, right click on them and chosse "Pivot"
  3. Name the column with the answers "Answers" (just for clarity. You should get a table that looks like this:

Now you need to create a calculated field (I called it Overthreshold to check for your condition:

if [Answer] > 3 then
[Answer]
End

At this point you could substitute the 3 with a parameter in case you want to easily change that condition. You can already drop the pills as follows to get the count:

Now if you want the percentage it gets a bit more complicated, since you have to determine the count of the questions and the count of the answers > 3 which is information that is stored in two different columns.

  1. Create another Calculated field with this calculation COUNT([Overthreshold]) / AVG({fixed [Question]:count([Answer])})
  2. drop the created pill onto the "text" field or into the columns drawer and see the percentage values
  3. right click on the field and choose Default Propertiess / Number Format to have it as percentage rather than a float

To explain what the formular does: It takes the count of the answers that are over the threshold and devides it by the count of answers for each question. This is done by the fixed part of the formular which counts the rows that have the same value in the Question column. The AVG is only there because Tableau needs an aggregeation there. Since the value will be the same for every record of the question, you could also use MIN or MAX.

It feels like there should be an eassier solution but right now I cannot think of one.

这篇关于如何计算tableau public中子集的值和百分比的出现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆