大佬教程收集整理的这篇文章主要介绍了使用电源查询合并Excel中的表,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用特定的表格配置来生成一个如下所示的级联下拉列表:
我想使用 excels powerquery 合并这些表以使其看起来像这样:
由于每个下拉列表都是不同的表格,因此您必须创建一个包含所有表格的列表。
创建供 PQ 操作的表列表可能很棘手。
在我的示例中,它们被命名为 Table19
- table26
,因此我使用了 List.Generate
函数来执行此操作。但是还有其他方法可以生成这样的列表,包括对其进行硬编码。
然后只需阅读所有表格,旋转和扩展即可。
查看代码中的注释以获得更好的理解。
@H_574_38@m 代码
let
//create a list of the relevant table names
// and create a column of the names
//many ways to do this
//Since mine are table19-26,I do it like this:
tablenames = List.Generate(
()=>[Table Name = "Table" & "19",IDX=20],each [IDX] < 28,each [Table Name = "Table" & Text.From([IDX]),IDX = [IDX]+1],each [Table Name]
),#"Converted to Table" = Table.FromList(tablenames,Splitter.SplitByNothing(),null,ExtraValues.Error),//Add custom column containing the actual table referred to in column1
//then delete the table names column
#"Added Custom" = Table.Addcolumn(#"Converted to Table","Tables",each Excel.CurrentWorkbook(){[Name=[column1]]}[Content]),#"Removed columns" = Table.Removecolumns(#"Added Custom",{"column1"}),//add custom column to unpivot each of the tables
//then remove the original tables column and expand the unpivoted column
#"Added Custom1" = Table.Addcolumn(#"Removed columns","unPivot",each
Table.UnpivotOthercolumns([Tables],{},"Type","Subtype")),#"Removed columns1" = Table.Removecolumns(#"Added Custom1",{"Tables"}),#"Expanded unPivot" = Table.ExpandTablecolumn(#"Removed columns1",{"Type","Subtype"},"Subtype"})
in
#"Expanded unPivot"
以上是大佬教程为你收集整理的使用电源查询合并Excel中的表全部内容,希望文章能够帮你解决使用电源查询合并Excel中的表所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。