Table.ExpandTableColumn仅第一行

时间:2019-11-07 03:13:56

标签: powerbi powerquery

我想使用Power Query使用Table.ExpandTableColumn.提取相关表,而不是扩展整个相关表,我只想扩展第一行。

在下面的尝试中,我提取了整个“名称” 列。

= Table.ExpandTableColumn(#"Changed Type", "ToRecipients", {"Name"}, {"ToRecipients.Name"})

有什么想法吗?

保罗

2 个答案:

答案 0 :(得分:0)

这将如何工作?

Table.ExpandTableColumn(

    // Retaining only first rows in the nested tables
    Table.TransformColumns(#"Changed Type", {"Name", each Table.FirstN(_, 1)}),

    "ToRecipients", {"Name"}, {"ToRecipients.Name"}
)

或者,

Table.ExpandRecordColumn(

    // Retaining only first rows in the nested tables as 'records'
    Table.TransformColumns(#"Changed Type", {"Name", Table.First}),

    "ToRecipients", {"Name"}, {"ToRecipients.Name"}
)

两者都一样。稍后可能看起来更简单一点?

答案 1 :(得分:0)

猜猜它应该像下面这样;

= Table.ExpandTableColumn( Table.TransformColumns(
                      #"Changed Type", {"ToRecipients", each Table.FirstN(_, 1)}),

"ToRecipients", {"Name"}, {"ToRecipients.Name"})

...

Table.ExpandRecordColumn(

// Retaining only first rows in the nested tables as 'records'
Table.TransformColumns(#"Changed Type", {"ToRecipients", Table.First}),

"ToRecipients", {"Name"}, {"ToRecipients.Name"})