Power Query将不同的列表合并到表中 [英] Power Query merge distinct lists into table

查看:59
本文介绍了Power Query将不同的列表合并到表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Excel表格,其中的数据为多列.我正在尝试创建另一个仅用于唯一值的单元内下拉列表.我需要在每列之间独立获取唯一值.

I have a excel table with data in multiple columns. I am trying to create another table that will be used for in-cell dropdown with only unique values. I need to get unique values independently between each columns.

源表

geo   product   type
g1    p1        t1
g1    p2        t1
g1    p3        t2
g1    p4        t1
g2    p1        t2
g2    p2        t1
g2    p3        t2
g2    p4        t1

预期结果:

geo   product   type
g1    p1        t1
g2    p2        t2
null  p3        null
null  p4        null

我可以获得唯一的列作为列表

I can get unique columns as lists

geo_list = List.Distinct(Table.Column(Source, "geo"))
product_list = List.Distinct(Table.Column(Source, "product"))
type_list = List.Distinct(Table.Column(Source, "type"))

但是无法找到一种无需任何连接即可将其合并到一个表中的方法.

But cannot find a way how to merge it into one table without any kind of join.

推荐答案

类似于这篇文章,您可以使用 Table.FromColumns 从列表中组装表格.

Similar to this post, you can use Table.FromColumns to assemble a table from your lists.

Table.FromColumns(
    {
        List.Distinct(Source[geo]),
        List.Distinct(Source[product]),
        List.Distinct(Source[type])
    },
    {"geo","product","type"}
)

这篇关于Power Query将不同的列表合并到表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆