【问题标题】:Power Query: How to add column with repeating valuesPower Query:如何添加具有重复值的列
【发布时间】:2020-01-27 23:19:10
【问题描述】:

我有一个包含 ProductCodeProductDescriptionSales 字段的 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

让我知道它是否有效

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多