【问题标题】:Power Query: How to add column with repeating valuesPower Query:如何添加具有重复值的列
【发布时间】:2020-01-27 23:19:10
【问题描述】:
我有一个包含 ProductCode、ProductDescription 和 Sales 字段的 Excel 表。我想添加一个名为“Store”的列,其中的值来自某些标题行,如下图所示。
谢谢!
原文:
想要的结果:
Sample File
【问题讨论】:
标签:
excel
powerquery
customcolumn
【解决方案1】:
这将提取商店并将其放在另一列中
Source 行中的Test 是表的名称
let
Source = Excel.CurrentWorkbook(){[Name="Test"]}[Content],
ChangeTypes = Table.TransformColumnTypes(Source,{{"ProductCode", type text}, {"ProductDescription", type text}, {"Sales", Int64.Type}}),
AddStoreCol = Table.AddColumn(ChangeTypes, "Store", each if [ProductDescription] = null and Text.Start([ProductCode],5) <> "TOTAL" then [ProductCode] else null, type text),
FillDown = Table.FillDown(AddStoreCol,{"Store"}),
FilterNulls = Table.SelectRows(FillDown, each [ProductDescription] <> null and [ProductDescription] <> "")
in
FilterNulls
让我知道它是否有效