如何按列名筛选,并使Tableau中的值相应更改?

huangapple go评论73阅读模式
英文:

How to filter by column name and make the values change accordingly in Tableau?

问题

我正在处理一个关于心脏衰竭的数据集。它包含四个表格,我想创建一个仪表板,用于探索不同疾病如何影响血液指标、性别(男性、女性)和年龄。这些疾病包括糖尿病、吸烟、高血压等。

在这个数据集中,这些列是布尔型的。也就是说,糖尿病可以是1,如果这个人患有糖尿病,否则为0。死亡事件的列也是一样,如果在研究期间这个人死亡,该值为1,否则为0。

然后,我有类似这样的数据:

Unique ID | Value 1 | Value 2 | 贫血 | 高血压 | ... | 死亡事件

1     |  0.484  |  1.354  |   1   |    0    | ... |      0

这意味着这个特定的人患有贫血,但没有高血压,没有死亡,还有不同的血液值和其他数据。

我想要创建一个筛选器,如下所示:

使用列名进行筛选

当我选择其中一个列名时,饼图应相应调整,显示数据集中患有该疾病的死亡和存活人员的比例。

期望的结果,也可以是柱状图

为了解决我的问题,我进行了一些研究,发现我可以使用参数(这是我用来创建第一张图片中的筛选器的方法)并与计算字段结合使用,但我还需要汇总:显示在数据集中患有该疾病的死亡和存活人员的数量。

我尝试了[疾病] = [疾病参数]的方法,但这不起作用,因为我需要多个列以及一个聚合。

我还尝试了使用如下类型的计算字段:

用于匹配字符串条件的计算字段

但在这一点上,我迷失方向。

提前感谢您的帮助。

英文:

Im working with a dataset to heart failure. It contains four tables and I want to create a dashboard that revolves around exploring how different afflictions affect blood values, sex (male, female) and age. These afflictions are, for example, diabetes, smoking, high blood pressure, etc.

In this dataset, those columns are booleans. That is, Diabetes can either be 1, if the person had it, or 0 otherwise. The same happens to the column of death events. If the person died during the study, the value is 1, or 0 otherwise.

Then, I have something like:

Unique ID | Value 1 | Value 2 | Anaemia | High Blood Pressure | ... | death_event

1     |  0.484  |  1.354  |    1    |        0            | ... |      0

Which means that particular person had anaemia, but not high blood pressure and didnt die, along with different blood values and other data.

What I want is to create a filter like the following:

filter using column names

And when I select one of the column names, a pie chart would adjust accordingly, showing the proportion of deaths and alive people that had that affliction within the dataset.

Kind of desired result, could also be a bar plot

To try to solve my issue I did a little bit of research and found that I could use a Parameter (which is what I used to create the filter shown in the first image) and combine it with a Calculated Field, but I also need the aggregation: show the amount of dead and alive people with that condition within the dataset.

I tried the [Affliction] = [Affliction Parameter] method, but that doesnt work since I need multiple columns and also an aggregation.

I also tried to work with calculated fields of the type:

calculated field to match string contidion

but at this point Im lost.

Thanks in advance for your help.

答案1

得分: 0

以下是已翻译的内容:

这里有一种方法来做这个。
创建一个名为[Sort Metric]的参数,选择字符串和列表。
在列表名称中输入两个或更多字段的名称。
假设其中一个是[销售],另一个是[客户ID]。
创建一个计算字段[Sort by Metric]

IF [Sort Metric] = '销售' THEN SUM([销售])
ELSEIF [Sort Metric] = '客户ID' THEN COUNTD([客户ID])
END

在视图或仪表板中显示参数。
右键单击要排序的字段。选择按字段选择[Sort by Metric]升序或降序。聚合应为"自定义"。
切换参数将使用其他聚合方法。

英文:

Here's a way to do this.
Create a parameter called [Sort Metric] Select String and list.
Type the names of the two or more fields in the list names.
Let's say one is [Sales] and one is [Customer ID].
Create a calculated field [Sort by Metric]

IF [Sort Metric]='Sales' THEN SUM([Sales])
ELSEIF [Sort Metric]='Customer ID' THEN COUNTD([Customer ID])
END

Show the parameter in the view or dash.
rt-click the pill that you want to sort. Choose by field select [Sort by Metric] Ascending or descending.. Aggregation should be "Custom"
Switching the parameter will use the other aggregation.

huangapple
  • 本文由 发表于 2023年3月7日 08:02:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75656905.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定