如果/然后计算,以捕获所有特定字符

发布于 2025-02-13 21:27:05 字数 1488 浏览 0 评论 0原文

我有一个来自SharePoint的数据集,用户可以从Tableau中选择多个选项作为答案。这些显示在用“;”划界的图表表中的组合选择。

一个答案可以显示为单一选择,例如:

| Classification |
| -------------- |
| SelectionA     |

来更改此名称的名称

IF [Classification] = "SelectionA" THEN "New Name" END

我可以使用一个简单的if/then以我的障碍物 休息。 例如:

| Classification                   |
| -------------------------------- | 
| SelectionA;SelectionB;SelectionC | 
| Thing1;Thing2;Thing3, etc        | 

我想拥有具有多种选择的人来形成一个新名称。我已经输入了此内容,但不确定该陈述和嵌套循环在两个下都无法正常工作,

IF [Classification] = "SelectionA" THEN "New Name" 
ELSEIF [Classification] = "SelectionA;" THEN "New Name+"
ELSEIF [Classfication] = "Thing1" THEN "New Thing"
ELSEIF [Classfication] = "Thing1;" THEN "New Thing+"
END

并且

IF SPLIT ([Classification], ";",1) = "SelectionA" THEN
    IF SPLIT ([Classification], ";",2) IF NOT ISNULL THEN "New Name+"
    ELSE "New Name"
    END
ELSEIF SPLIT ([Classification], ";",1) = "SelectionA.1" THEN
    IF SPLIT ([Classification], ";",2) IF NOT ISNULL THEN "New Name+"
    ELSE "New Name"
    END

最终导致我的头部

| Classification                   | Classificaiton(new)
| -------------------------------- | -------------------
| SelectionA                       | New Name
| SelectionA;SelectionB;SelectionC | New Name+
| Thing1                           | New Thing
| Thing1;Thing2;Thing3, etc        | New Thing+

I have a dataset from SharePoint that users can select multiple options from as an answer that I want to reflect in Tableau. These show as combined selections in a Tableau table deliminated with a ";".

One answer could show up as a single-selection such as:

| Classification |
| -------------- |
| SelectionA     |

I can change the name of this using a simple IF/THEN for multiple single-selections with

IF [Classification] = "SelectionA" THEN "New Name" END

My obstacle is separating out the multiple-selections and adding a 'catch all' for the rest.
For example:

| Classification                   |
| -------------------------------- | 
| SelectionA;SelectionB;SelectionC | 
| Thing1;Thing2;Thing3, etc        | 

I would like to have those with multiple-selections to form a new name. I have typed this but am not sure where to proceed since the statement and nested loop below both do not work

IF [Classification] = "SelectionA" THEN "New Name" 
ELSEIF [Classification] = "SelectionA;" THEN "New Name+"
ELSEIF [Classfication] = "Thing1" THEN "New Thing"
ELSEIF [Classfication] = "Thing1;" THEN "New Thing+"
END

AND

IF SPLIT ([Classification], ";",1) = "SelectionA" THEN
    IF SPLIT ([Classification], ";",2) IF NOT ISNULL THEN "New Name+"
    ELSE "New Name"
    END
ELSEIF SPLIT ([Classification], ";",1) = "SelectionA.1" THEN
    IF SPLIT ([Classification], ";",2) IF NOT ISNULL THEN "New Name+"
    ELSE "New Name"
    END

With the end result in my head as

| Classification                   | Classificaiton(new)
| -------------------------------- | -------------------
| SelectionA                       | New Name
| SelectionA;SelectionB;SelectionC | New Name+
| Thing1                           | New Thing
| Thing1;Thing2;Thing3, etc        | New Thing+

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦亿 2025-02-20 21:27:05

您的数据中有一对多的关系。

我将重点介绍在数据库(或数据存储)中以清晰逻辑的方式表示数据,然后担心可视化

关系数据库中的标准方法是用两个表表示数据 - 其中一个表具有列(称为外键),引用了另一个表。问题在于,SharePoint通过将多个值塞入这些单元格中来打破标准的关系数据库模型。也许这使得SharePoint的一些事情变得更加容易,但是试图分析数据的问题并没有终止问题。感谢Microsoft :-(

您可以使用Tableau Prep或Python将数据转换为更结构化/归一化的关系模型,

例如,如果每个母亲都有很多孩子(因此每个孩子都有一个单身母亲),那么您将有一张桌子(例如称为女人)和其他桌子(称为孩子)。对于每个记录 - 称为主要钥匙也将有一个名为Mother_id的列(也许是Woman_id),将每个孩子与该模型相关

联您确实将数据具有更合理的结构,有几种选择显示的方法。

You have a one-to-many relationship in your data.

I would focus on representing the data in a clear and logical way in the database (or data store) and then worry about the visualization

The standard approach in relational databases is to represent the data with two tables -- where one table has a column (known as a foreign key) that references the other table. The problem is that SharePoint breaks the standard relational database model by cramming multiple values into these cells. Perhaps that makes a few things easier in SharePoint, but it causes no end of problems trying to analyze the data. Thanks Microsoft :-(

You can use Tableau Prep or Python to convert the data to more structured/normalized relational model

For instance, if each mother has many children (and thus each child has a single mother) then you would have one table (say called Woman) and other table (say called Child). Each row in the Woman table represents exactly one woman and each row in the Child table represents exactly one child. Each table would have a single column (say called ID) with a unique ID for each record - called a primary key. The child table also would have a required column called mother_ID (or perhaps woman_ID) which associates each child with its mother. Note with this model, you can have women who have no associated children, but each child has exactly one mother.

Once you do have your data in a more reasonable structure, there are several ways to choose to display it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文