- //Unnamed
- let
- 源 = Folder.Files("C:\Users\飞飞\Desktop\求助"),
- 筛选的行 = Table.SelectRows(源, each not Text.Contains([Name], "汇")),
- 筛选的隐藏文件1 = Table.SelectRows(筛选的行, each [Attributes]?[Hidden]? <> true),
- 调用自定义函数1 = Table.AddColumn(筛选的隐藏文件1, "转换文件", each 转换文件([Content])),
- 重命名的列1 = Table.RenameColumns(调用自定义函数1, {"Name", "Source.Name"}),
- 删除的其他列1 = Table.SelectColumns(重命名的列1, {"Source.Name", "转换文件"}),
- 扩展的表格列1 = Table.ExpandTableColumn(删除的其他列1, "转换文件", Table.ColumnNames(转换文件(示例文件))),
- 删除的其他列 = Table.Buffer(Table.SelectColumns(扩展的表格列1, {"时间", "成交金额", "新增粉丝数", "评论次数"})),
- 更改的类型 = Table.TransformColumnTypes(
- 删除的其他列,
- {
- {"成交金额", Currency.Type},
- {"时间", type datetime},
- {"新增粉丝数", Int64.Type},
- {"评论次数", Int64.Type}
- }
- ),
- 已添加自定义 = Table.AddColumn(
- 更改的类型,
- "主播",
- each List.Accumulate(
- {0 .. Table.RowCount(表1) - 1},
- "",
- (x, y) => x & (if [时间] >= 表1{y}[上播时间] and [时间] <= 表1{y}[下播时间] then 表1{y}[主播] else "")
- )
- ),
- 分组的行 = Table.Group(
- 已添加自定义,
- {"主播"},
- {
- {"销售额", each List.Sum([成交金额]), type nullable number},
- {"涨粉数", each List.Sum([新增粉丝数]), type nullable number},
- {"评论数", each List.Sum([评论次数]), type nullable number},
- {"播出时长", each Text.From(Number.Round(Table.RowCount(_) / 60, 2)) & "小时"}
- }
- )
- in
- 分组的行
复制代码 |