电源查询;过滤以仅显示一个值组合

发布于 2025-02-12 04:36:36 字数 1118 浏览 0 评论 0原文

我正在尝试使用Excel Power查询将列的一个组合过滤为:

示例:

原始表:

Header1Header2
ab b
bb
b bc

期望的结果:

header1header2 header2
ab
bc

可以是ab/ba的任何组合只要只有一个。

我包括了一个未完成查询的演示工作簿的链接。尝试多种方法使它起作用。

PQ组合转换帮助

任何人都可以借用他们的专业知识来帮助实现这一目标吗?

I'm trying to use Excel Power Query to filter down to only one combination of columns:

Example:

Original Table:

Header1Header2
AB
BA
BC

Desired Result:

Header1Header2
AB
BC

Could be any combination of AB/BA as long as there is only one.

I've included a link to a demo workbook with the unfinished query. I've been going crazy trying multiple methods to get this to work.

PQ Combination Transform Help

Can anyone lend their expertise to help get this working?

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

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

发布评论

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

评论(2

眼前雾蒙蒙 2025-02-19 04:36:37

哪些确定最后两行要保留?我猜您是说Header1与Header2对,不考虑其余列?

通常,如果要创建唯一的对,基本上是复合主键 - 可以

使用table.group

在UI中 选择组,然后选择Header1> header2。现在,您有了一对不同的一对。

表格

,或者您可以使用

= Table.Distinct( Source, {"Header1", "Header2"} )

What determines which of the last 2 rows is kept? I'm guessing you mean the pairs of Header1 with header2, not considering the remaining columns?

Normally if you want to create unique pairs, basically a Composite Primary Key -- you can use

Table.Group

Choose group by in the UI, and select Header1 and Header2. Now you have a distinct set of the pair.

Table.Distinct

Or you can use

= Table.Distinct( Source, {"Header1", "Header2"} )
何其悲哀 2025-02-19 04:36:36

请参阅算法中的代码中的注释

let
    Source = Excel.CurrentWorkbook(){[Name="Table7"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Header1", type text}, {"Header2", type text}}),

//add custom column with a concatenated **sorted** version of the original two columns
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Sort({[Header1]} & {[Header2]})),

//Remove duplicates based on the concatenated column
    #"Removed Duplicates" = Table.Distinct(#"Added Custom", {"Custom"}),
    #"Removed Columns" = Table.RemoveColumns(#"Removed Duplicates",{"Custom"})
in
    #"Removed Columns"

。 png“ alt =”在此处输入图像说明”>

See comments in code for the algorithm

let
    Source = Excel.CurrentWorkbook(){[Name="Table7"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Header1", type text}, {"Header2", type text}}),

//add custom column with a concatenated **sorted** version of the original two columns
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Sort({[Header1]} & {[Header2]})),

//Remove duplicates based on the concatenated column
    #"Removed Duplicates" = Table.Distinct(#"Added Custom", {"Custom"}),
    #"Removed Columns" = Table.RemoveColumns(#"Removed Duplicates",{"Custom"})
in
    #"Removed Columns"

enter image description here

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