问题描述
Power BI获取SharePoint List列表作为数据源。但是在数据源中,有Table属性值,有List属性值。如果直接展开,则会形成"笛卡尔"集的效果,变成N多行数据。
效果图如下:

但是,我们最终所需要的效果是:
保留整体表格的行数不变,把Table中所需要的字段,List中的值使用"逗号"分隔,展示在一行中。

那么,在真实的Sharepoint List + Power BI中,如何来展开List/Table中的字段呢? 如何来使用 " , " 拼接呢?
问题解答
解决以上的问题,主要使用的知识点为:
1)在Table属性列,通过"添加新列",从Table中取出Column2列中的值,形成一个新的List列
#"Added Custom" = Table.AddColumn(#"SharePoint List", "Custom", each [Count][Column2]),
2)在新的List列中,通过 Text.Combine 函数把List中的全部值转换为目标字符串
#"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
详细操作步骤如下:
步骤一:在Table列中,展开查看Table中的数据及列名
点击Add Column --> Custome Column --> 选择正确的列(这里是Text) --> 在第4点中,需要手动输入Text表中的列名。

点击OK后,新的数据结构为List。

第二步:展开List,并且使用Comma分隔
点击列头右边的展开符号,选择"Extract Values..."后,并选择 Comma分隔。

最终效果,达到了把 Table --> List --> String 的目的。
动态效果图

完整的Power BI Query语句为
let
Source = Table.FromRows(),
#"SharePoint List" = ... ... .... .... ,
#"Renamed Columns" = Table.RenameColumns(#"SharePoint List",{{"Column1", "ID"}, {"Count", "Text"}}),
#"Added Custom" = Table.AddColumn(#"Renamed Columns", "Custom", each [Text][Column2]),
#"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
#"Replaced Errors" = Table.ReplaceErrorValues(#"Extracted Values", {{"Custom", " < no value >"}}),
#"Replaced Value" = Table.ReplaceValue(#"Replaced Errors",null,"<no null>",Replacer.ReplaceValue,{"Custom"})
in
#"Replaced Value"
参考资料
SharePoint list expand table column : https://community.fabric.microsoft.com/t5/Desktop/SharePoint-list-expand-table-column/td-p/2150752