如何通过 pq 实现如下操作

Power Query 遇见甜津津 ⋅ 于 2019-07-03 17:24:45 ⋅ 最后回复由 遇见甜津津 2019-07-04 10:52:21 ⋅ 2624 阅读

请教大神怎么实现这样的效果file

成为第一个点赞的人吧 :bowtie:
最佳答案
  • Hardy
    2019-07-03 18:46:46

    let
    Source = Excel.CurrentWorkbook(){[Name="表3"]}[Content],

    "Changed Type" = Table.TransformColumnTypes(Source,{{"日期", type date}, {"id", type text}, {"金额", Int64.Type}, {"销量", Int64.Type}}),

    #"Unpivoted Only Selected Columns" = Table.Unpivot(#"Changed Type", {"金额", "销量"}, "属性", "值"),
    #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Unpivoted Only Selected Columns", {{"日期", type text}}, "zh-CN"),{"日期", "属性"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"已合并"),
    #"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns"[已合并]), "已合并", "值"),
    #"Reordered Columns" = Table.ReorderColumns(#"Pivoted Column",{"id", "2019/6/5 金额", "2019/6/6 金额", "2019/6/7 金额", "2019/6/5 销量", "2019/6/6 销量", "2019/6/7 销量"})

    in

    "Reordered Columns"

回复数量: 2
  • Hardy
    2019-07-03 18:46:46

    let
    Source = Excel.CurrentWorkbook(){[Name="表3"]}[Content],

    "Changed Type" = Table.TransformColumnTypes(Source,{{"日期", type date}, {"id", type text}, {"金额", Int64.Type}, {"销量", Int64.Type}}),

    #"Unpivoted Only Selected Columns" = Table.Unpivot(#"Changed Type", {"金额", "销量"}, "属性", "值"),
    #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Unpivoted Only Selected Columns", {{"日期", type text}}, "zh-CN"),{"日期", "属性"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"已合并"),
    #"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns"[已合并]), "已合并", "值"),
    #"Reordered Columns" = Table.ReorderColumns(#"Pivoted Column",{"id", "2019/6/5 金额", "2019/6/6 金额", "2019/6/7 金额", "2019/6/5 销量", "2019/6/6 销量", "2019/6/7 销量"})

    in

    "Reordered Columns"

  • 遇见甜津津
    2019-07-04 10:52:21

    @Hardy 谢谢您

暂无评论~~
  • 请务必阅读并严格遵守《社区管理规范与使用说明》
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`, 更多语法请见这里 Markdown 语法
  • 支持表情,使用方法请见 发送表情,可用的 Emoji 见 :metal: :point_right: Emoji 列表 :star: :sparkles:
  • 上传图片, 支持拖拽和剪切板粘贴上传, 格式限制 - jpg, png, gif
  • 不支持上传附件,请尽可能用文字和图片将问题描述清楚,如实在需要上传附件,可上传到 共享网盘 后分享链接
  • 发布框支持本地存储功能,会在内容变更时保存,「提交」按钮点击时清空
  请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!
Ctrl+Enter