PowerBi-条件列精确匹配

发布于 2025-02-11 23:35:49 字数 2160 浏览 2 评论 0原文

我有下面的“动作”列,我想从“非正式”和“正式”中得出两个条件列。如果动作列中有非正式,那么我想要非正式列中的“ 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
福利检查。非正式会议。YY
Informal counselling and mediationYY
formal counselling second formal warningY
Informal CounsellingYY
Formal counselling - formal warning pending mitigationsY
Formal meeting, pending mitigations a formal warningY
formal counselling + formal warning.针对其他2名受访者的非正式咨询,等待参与。yy

所需的表:

行动非正式的正式
非正式讨论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

ActionInformalFormal
Informal discussionYY
formal counselling with formal warningY
formal counselling and formal warningY
Welfare check. Informal meeting.YY
Informal counselling and mediationYY
formal counselling second formal warningY
Informal CounsellingYY
Formal counselling - formal warning pending mitigationsY
Formal meeting, pending mitigations a formal warningY
formal counselling + formal warning. Informal counselling for 2 other respondents pending involvement.YY

Desired table:

ActionInformalFormal
Informal discussionY
formal counselling with formal warningY
formal counselling and formal warningY
Welfare check. Informal meeting.Y
Informal counselling and mediationY
formal counselling second formal warningY
Informal CounsellingY
Formal counselling - formal warning pending mitigationsY
Formal meeting, pending mitigations a formal warningY
formal counselling + formal warning. Informal counselling for 2 other respondents pending involvement.YY

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

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

发布评论

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

评论(2

痴骨ら 2025-02-18 23:35:52

我认为如果非正式为y,那么正式必须为零,所以为什么不设定正式的公式

= if [Informal] ="Y" then null else "Y"

I assume that if Informal is Y then Formal has to be null so why not set the formula for Formal to be

= if [Informal] ="Y" then null else "Y"
智商已欠费 2025-02-18 23:35:52

处理句子时,我有一个以前在VBA中使用过的技巧。

  1. 使用text.split功能“” (space)作为saparator,将文本字符串变成列表。它为您提供了字符串中的单词列表。
  2. 查看此列表中的“正式”或“非正式”此列表,这是list.contains函数。

这是“正式”列的代码:

= Table.AddColumn(#"Changed Type", "Formal", each if List.Contains(Text.Split([Action], " "), "formal") then "Y" else null)

I have a trick that I've previously used in VBA when processing sentences.

  1. Turn the string of text into a list using the Text.Split function with " " (space) as separator. It gives you a list of the words in your string.
  2. Look into this list for either "formal" or "informal" this the List.Contains function.

Here is the bit of code for the column "Formal":

= Table.AddColumn(#"Changed Type", "Formal", each if List.Contains(Text.Split([Action], " "), "formal") then "Y" else null)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文