简体   繁体   English

从是/否列获取 Tableau 中的百分比

[英]Getting a percentage in Tableau from a yes/no column

I have a spreadsheet of support case management data.我有一个支持案例管理数据的电子表格。 I am working with this in Tableau.我正在 Tableau 中处理这个问题。 Each line in the spreadsheet is an individual case.电子表格中的每一行都是一个单独的案例。 Each case has, among much else, a support agent name and a Yes or No of whether the case work was started within 12 hours.除其他外,每个案例都有一个支持代理名称以及案例工作是否在 12 小时内开始的“ Yes或“ No ”。 I'd like to know, for each agent, what percentage of the time they started the case work within 12 hours.我想知道,对于每个代理,他们在 12 小时内开始案例工作的时间百分比是多少。 So, if Bob has 2 "No" and 8 "Yes", he should have 8 / (2 + 8) = 80% .所以,如果鲍勃有 2 个“否”和 8 个“是”,他应该有8 / (2 + 8) = 80%

My attempt at this was to create 2 sets.我在这方面的尝试是创建 2 组。 One is the set of "Yes, started within 12 hours" (those that have "yes" in that field, and one that is the set of "No, not started within 12 hours", the complement to the other set. Silly me, I thought I could do something like COUNT(yeses) / COUNT(nos) . Nope, big red failure. So what is the right way to do this?一个是“是的,12小时内开始”的集合(那个领域有“是”的,一个是“不,12小时内没有开始”的集合,对另一组的补充。傻我,我想我可以做类似COUNT(yeses) / COUNT(nos)事情。不,大红色失败。那么正确的方法是什么?

It would help immensely to please respond as if this is the first thing I have ever done in Tableau.如果这是我在 Tableau 中所做的第一件事,请做出回应将非常有帮助。 It is.这是。 I have learned a lot in this project, but only in comparison to the nothing I knew previously.我在这个项目中学到了很多东西,但只是与我以前一无所知的东西相比。 Please also let me know if I've left out something necessary to answer this.如果我遗漏了一些必要的东西来回答这个问题,也请告诉我。 I've tried to be complete but, well, am noob...我试图变得完整,但是,好吧,我是菜鸟......

If it clarifies anything, here's a poor Excel mockup of data and the effect I'm looking for:如果它澄清了什么,这是一个糟糕的 Excel 数据模型和我正在寻找的效果:

在此处输入图片说明

You could create another column that converts the Yes's into 1's, and the No's into 0's.您可以创建另一列,将 Yes 转换为 1,将 No 转换为 0。 Sum up all the 1's and divide it by the total and that's your percentage.将所有的 1 相加并除以总数,这就是您的百分比。

edit: the new column would look something like编辑:新列看起来像

=IF(C3="Yes",1,0) =IF(C3="是",1,0)

in other words, if Cⁿ is "Yes", then 1, else 0换句话说,如果 Cⁿ 是“是”,则为 1,否则为 0

Yes, this is possible and easy in Tableau, but first a couple of points.是的,这在 Tableau 中是可能且容易的,但首先要说明几点。

The reason your attempt to use COUNT() did not work is that COUNT() does not operate the way you, and that 99% of the people on the planet, expect.您尝试使用 COUNT() 失败的原因是 COUNT() 的操作方式与您以及地球上 99% 的人所期望的方式不同。 COUNT([some expression]) returns the number of records that have a non-null value, any value, for [some expression]. COUNT([some expression]) 返回具有非空值(任何值)的 [some expression] 的记录数。 The name comes from SQL relational databases.该名称来自 SQL 关系数据库。

The calculations would be just a bit simpler if your third column took the boolean values True or False instead of the string values “Yes” or “No”.如果您的第三列采用布尔值 True 或 False 而不是字符串值“Yes”或“No”,则计算会简单一点。 (In which case you could drop '= “Yes”' from the formula below) (在这种情况下,您可以从下面的公式中删除 '= “Yes”')

So two ways to do your calculation are:因此,进行计算的两种方法是:

  1. Directly with an aggregate calculation which can get the right result, but is hard coded for this case, such as:直接使用聚合计算可以获得正确的结果,但在这种情况下是硬编码的,例如:

SUM(INT([Started within 24 hrs?] = “Yes”)) / SUM([Number of Records])

  1. Using a table calc - which in this case is a bit easier and more flexible.使用 table calc - 在这种情况下更容易和更灵活。 First, Build a table or viz in Tableau showing SUM([Number of Records]) with the dimensions you care about in play.首先,在 Tableau 中构建一个表或可视化,显示 SUM([Number of Records]) 和您关心的维度。 Say with [Name] on Rows, [Started within 24 hrs?] on Columns and SUM([Number of Records] on Text. Second, Right click on your measure SUM([Number of Records]) and choose Percentage of Total from the Quick Table Calc menu. Finally, use that same menu to adjust Compute Using to specify how you want the percentages computed - in this case, using [Started within 24 hrs?]说 [Name] 在 Rows 上,[Started within 24 hrs?] 在 Columns 和 SUM([Number of Records] on Text。第二,右键单击您的度量 SUM([Number of Records]) 并从Quick Table Calc 菜单。最后,使用相同的菜单调整 Compute Using 以指定您希望如何计算百分比 - 在这种情况下,使用 [Started within 24 hrs?]

If you only want to show some of the data, right click on the column header for the values you wish to hide and choose Hide.如果您只想显示部分数据,请右键单击要隐藏的值的列标题,然后选择隐藏。

The type conversion function INT() converts True to 1 and False to 0.类型转换函数 INT() 将 True 转换为 1,将 False 转换为 0。

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

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