excel - 使用 PowerQuery 在 Excel 中堆叠列对

标签 excel powerquery

我有一个在电源查询中生成的表,当前格式如下


一个
键1
值(value)1
键2
值(value)2


A1
B1
C1
D1
E1


我想


一个
key
值(value)


A1
B1
C1

A1
D1
E1


这在电源查询中如何实现?

最佳答案

彼得的回答有效,或者让它更通用:

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
base=1,   // # leading columns that will repeat
group=2,  // followed by groups of 2 columns
Combo = List.Transform(List.Split(List.Skip(Table.ColumnNames(Source),base),group), each List.FirstN(Table.ColumnNames(Source),base) & _),
#"Added Custom" =List.Accumulate(
        Combo, 
        #table({"Column1"}, {}),
        (state,current)=> state & Table.Skip(Table.DemoteHeaders(Table.SelectColumns(Source, current)),1)
)
in #"Added Custom"
enter image description here

关于excel - 使用 PowerQuery 在 Excel 中堆叠列对,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71959521/

相关文章:

excel - 对于工作表中的每一列,在单元格中搜索一个值,然后选择该列并在该列之前插入一列

excel - VBA运行时错误 '380' : A script engine for the specified language can not be created

excel - 对于 Power Query 中列中每个值第一次出现的情况,返回 1,否则返回 0

excel - PowerQuery:避免每次添加列时重新加载

powerbi - 如何在 Power Query 中交叉连接(笛卡尔积)

date - Power Query 过滤器日期从今天减去?天到今天

excel - VBA 验证列表默认值

java - 无法使用 JXL API 在 Excel 中查看组合框

powerquery - excel power 查询中来自用户名的 facebook userid

excel - 从第三方黑莓应用程序启动 Documents To Go 应用程序