Dav*_*542 5 excel m powerquery powerbi
如果我有以下来源:
#"My Source" = Table.FromRecords({
[Name="Jared Smith", Age=24],
[Name = "Tom Brady", Age=44],
[Name="Hello Tom", Age = null],
[Name = "asdf", Age = "abc"]
}),
Run Code Online (Sandbox Code Playgroud)
如何从值列表中添加新列,例如:
Table.AddColumn(#"My Source", "New Col", {'x', 'y', 'z', null})
Run Code Online (Sandbox Code Playgroud)
现在我的表格将包含三列。这怎么可能做到呢?
这是另一种方法。它开始时与 Ron 使用的方法类似,通过添加索引,但随后不使用合并,而是仅使用索引作为对相应列表项的引用。
let
Source1 = Table.FromRecords({
[Name="Jared Smith", Age=24],
[Name = "Tom Brady", Age=44],
[Name="Hello Tom", Age = null],
[Name = "asdf", Age = "abc"]
}),
#"Added Index" = Table.AddIndexColumn(Source1, "Index", 0, 1),
#"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each {"x", "y", "z", null}{[Index]}),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"})
in
#"Removed Columns"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7608 次 |
| 最近记录: |