强大的查询-转置唯一值并在行中获取匹配值 [英] Power Query - Transpose unique values and get matching values in rows
本文介绍了强大的查询-转置唯一值并在行中获取匹配值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试转换一个非常简单的input_table
I am trying to transform a very simple input_table
进入此output_table:
into this output_table:
我基本上是在尝试:
- 在第一列中获取唯一项
- 将这些项目转置并提升为列标题
- 在每个唯一标题下获取匹配值(从 input_table 中的第二列)
- Get unique items in first column
- Transpose and promote these items as column headers
- Get matching values (from the second column in input_table) under each unique header
我使用Power Query是因为每次将记录添加到 input_table 时,我都需要 output_table 动态更新,但是可以接受任何其他动态解决方案(数组公式,中间桌子等).没有VBA.
I am using Power Query because I need the output_table to dynamically update each time I add records to input_table, but any other dynamical solution is accepted (Array Formulas, intermediate Tables, etc...). No VBA.
推荐答案
假设您的表名为Table1,并且其结构如屏幕截图所示,我认为此Power Query查询应该可以满足您的要求:
Assuming your table is called Table1 and is structured in the way shown in the screenshot, I think this Power Query query should do what you want:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
ChangedType = Table.TransformColumnTypes(Source,{{"Type", type text}, {"Value", type text}}),
GroupedRows = Table.Group(ChangedType, {"Type"}, {{"DistinctValues", each _[Value]}}),
Output = Table.FromColumns(GroupedRows[DistinctValues], GroupedRows[Type])
in
Output
克里斯
这篇关于强大的查询-转置唯一值并在行中获取匹配值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文