如何在 PowerQuery 中的重复项之间添加空白行?

问题描述 投票:0回答:1

我有一个正在 PowerQuery 编辑器中编辑的数据表。电子表格格式如下:

Example excel data

表格按 ID 号排列重复项。我的最终用户更喜欢在重复项之间插入一个空白行。通常我会在 Excel 中手动执行此操作,并且可以继续执行此操作,但是有没有办法让 PowerQuery 自动在重复项之间插入空白行?

我尝试在网上寻找可以提供一些帮助的资源。我发现的一切都没有那么有帮助。我正处于学习 PowerQuery 的开始阶段,所以如果这个问题的答案非常简单,我先发制人地道歉! :)

excel duplicates formatting row powerquery
1个回答
0
投票

powerquery 中的一种方法。这组上

let  Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type),
#"Grouped Rows" = Table.Group(#"Added Index", {"ID"}, {{"data", each _& #table({"Index"},{{List.Last(_[Index])+.01}}), type table}}),
#"Removed Other Columns" = Table.SelectColumns(#"Grouped Rows",{"data"}),
ColumnsToExpand = Table.ColumnNames( #"Removed Other Columns"[data]{0} ),
#"Expanded data" = Table.ExpandTableColumn(#"Removed Other Columns" , "data", ColumnsToExpand,ColumnsToExpand),
#"Sorted Rows" = Table.Sort(#"Expanded data",{{"Index", Order.Ascending}}),
#"Removed Columns" = Table.RemoveColumns(#"Sorted Rows",{"Index"})
in #"Removed Columns"
© www.soinside.com 2019 - 2024. All rights reserved.