基于条件的电源查询列

发布于 2025-02-13 09:55:38 字数 687 浏览 0 评论 0原文

大家好,刚接触BI的刚接触BI,我在基于电源查询的条件下创建一列遇到了一些麻烦。

我正在尝试做一些事情,例如上一个字母是a,b或c,而当前的字母为e,f或g mark true,否则是错误的。

到目前为止,我的代码看起来像这样:

自定义列=

如果list.contains({“ a”,“ b”,“ c”}),[prectletter]

和list.contains({“ e”,“ f”,“ g”,“ g ”}),[字母]

然后“ true”

否则“ false”

输出将是如此之类的东西:

prectletter字母customcolumn
afalsetrue
x mb falseb e true
cftrue true true
true任何f

帮助都非常感谢!

Hey guys new to Power BI here and I am having some trouble creating a column based on conditionals in Power Query.

I am trying to do something like if the previous letter was A,B,or C and the current letter is E,F,or G mark True, else False.

My code looks like this so far:

Custom Column =

IF List.Contains({“A”, “B”,”C”}), [PrevLetter]

AND list.Contains({“E”, “F”, ”G”}) , [Letters]

THEN “TRUE”

ELSE “FALSE”

Output would be so something like:

PrevLetterLetterCustomColumn
AFTrue
XMFalse
BETrue
CFTrue

Any help is truly appreciated!

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

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

发布评论

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

评论(1

深陷 2025-02-20 09:55:38

答案取决于您是否正在寻找单词中的字母,或者该字母是否代表整个文本,但是就您的

= if Text.PositionOfAny([PrevLetter], {"A", "B","C"})+Text.PositionOfAny([Letter], {"E", "F","G"})=0 then true else false

示例

= try if Text.PositionOfAny([PrevLetter], {"A", "B","C"})+Text.PositionOfAny([Letter], {"E", "F","G"})=0 then true else false otherwise false

= Table.AddColumn(Source, "Custom", each if List.ContainsAny({[PrevLetter]},{"A","B","C"}) and List.ContainsAny({[Letter]},{"D","E","F"}) then true else false  )

The answer depends on if you are looking for a letter within a word, or if that letter represents the entire text, but for your example, one answer could be

= if Text.PositionOfAny([PrevLetter], {"A", "B","C"})+Text.PositionOfAny([Letter], {"E", "F","G"})=0 then true else false

or if you want to plan around nulls

= try if Text.PositionOfAny([PrevLetter], {"A", "B","C"})+Text.PositionOfAny([Letter], {"E", "F","G"})=0 then true else false otherwise false

or

= Table.AddColumn(Source, "Custom", each if List.ContainsAny({[PrevLetter]},{"A","B","C"}) and List.ContainsAny({[Letter]},{"D","E","F"}) then true else false  )
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文