PowerBi-条件列精确匹配
我有下面的“动作”列,我想从“非正式”和“正式”中得出两个条件列。如果动作列中有非正式,那么我想要非正式列中的“ y”,同样,如果有正式的“ y”,则在正式列中。
使用PowerQuery与以下内容,我获得了这些列:
Table.AddColumn(#"Filtered Rows", "Informal", each if Text.Contains([#"Action"], "informal") then "Y" else if Text.Contains([#"Action"], "Informal") then "Y" else null)
但是
Table.AddColumn(#"Added Conditional Column1", "Formal", each if Text.Contains([#"Action"], "formal") then "Y" else if Text.Contains([#"Action"], "Formal") then "Y" else null)
,由于正式是非正式的,因此两列的重复是重复的。在PowerQuery环境中,我将如何进行确切的匹配(不敏感)。所需的表下方示例表。
数据集
行动 | 咨询的 | 采取正式 |
---|---|---|
非正式咨询 | , | 并 |
正式警告 | y | |
正式的咨询和正式警告 | y | |
福利检查。非正式会议。 | Y | Y |
Informal counselling and mediation | Y | Y |
formal counselling second formal warning | Y | |
Informal Counselling | Y | Y |
Formal counselling - formal warning pending mitigations | Y | |
Formal meeting, pending mitigations a formal warning | Y | |
formal counselling + formal warning.针对其他2名受访者的非正式咨询,等待参与。 | y | y |
所需的表:
行动 | 非正式的 | 正式 |
---|---|---|
非正式讨论 | y | |
正式警告 | y | |
正式咨询和正式警告 | y | |
福利检查。非正式会议。 | y | |
非正式咨询和调解 | y | |
正式咨询第二正式警告 | y | |
非正式咨询 | y | |
正式咨询 - 正式警告,等待缓解 | 正式 | |
会议,等待缓解,正式警告 | y | |
正式咨询 +正式警告。针对其他2名受访者的非正式咨询,等待参与。 | 是 | 的 |
I have a column below 'Action' which I want to derive two conditional columns from 'Informal' and 'Formal'. If there is an informal in the Action column then I want a 'Y' in the Informal column and likewise if there is a formal then 'Y' in Formal column.
Using PowerQuery with the following I obtained those columns with this:
Table.AddColumn(#"Filtered Rows", "Informal", each if Text.Contains([#"Action"], "informal") then "Y" else if Text.Contains([#"Action"], "Informal") then "Y" else null)
and
Table.AddColumn(#"Added Conditional Column1", "Formal", each if Text.Contains([#"Action"], "formal") then "Y" else if Text.Contains([#"Action"], "Formal") then "Y" else null)
However as seen there is duplication of the two columns as formal is in informal. How would I do an exact match (not case sensitive) in the PowerQuery environment. Desired table below example table.
Dataset
Action | Informal | Formal |
---|---|---|
Informal discussion | Y | Y |
formal counselling with formal warning | Y | |
formal counselling and formal warning | Y | |
Welfare check. Informal meeting. | Y | Y |
Informal counselling and mediation | Y | Y |
formal counselling second formal warning | Y | |
Informal Counselling | Y | Y |
Formal counselling - formal warning pending mitigations | Y | |
Formal meeting, pending mitigations a formal warning | Y | |
formal counselling + formal warning. Informal counselling for 2 other respondents pending involvement. | Y | Y |
Desired table:
Action | Informal | Formal |
---|---|---|
Informal discussion | Y | |
formal counselling with formal warning | Y | |
formal counselling and formal warning | Y | |
Welfare check. Informal meeting. | Y | |
Informal counselling and mediation | Y | |
formal counselling second formal warning | Y | |
Informal Counselling | Y | |
Formal counselling - formal warning pending mitigations | Y | |
Formal meeting, pending mitigations a formal warning | Y | |
formal counselling + formal warning. Informal counselling for 2 other respondents pending involvement. | Y | Y |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为如果非正式为y,那么正式必须为零,所以为什么不设定正式的公式
I assume that if Informal is Y then Formal has to be null so why not set the formula for Formal to be
处理句子时,我有一个以前在VBA中使用过的技巧。
text.split
功能“” (space)作为saparator,将文本字符串变成列表。它为您提供了字符串中的单词列表。list.contains
函数。这是“正式”列的代码:
I have a trick that I've previously used in VBA when processing sentences.
Text.Split
function with" "
(space) as separator. It gives you a list of the words in your string.List.Contains
function.Here is the bit of code for the column "Formal":