power query 透视和逆透视问题

源:
file
结果:
file
代码:

let
    源 = Excel.CurrentWorkbook(){[Name="表1"]}[Content],
    更改的类型 = Table.TransformColumnTypes(源,{{"列1", type text}, {"列2", type any}, {"列3", type any}, {"列4", type any}, {"列5", type any}}),
    转置表 = Table.Transpose(更改的类型),
    提升的标题 = Table.PromoteHeaders(转置表, [PromoteAllScalars=true]),
    更改的类型1 = Table.TransformColumnTypes(提升的标题,{{"Column1", type text}, {"姓名", type text}, {"畅心", Int64.Type}, {"篮球", Int64.Type}, {"冬", Int64.Type}, {"迷窍", Int64.Type}}),
    逆透视的列 = Table.UnpivotOtherColumns(更改的类型1, {"Column1", "姓名"}, "属性", "值"),
    已透视列 = Table.Pivot(逆透视的列, List.Distinct(逆透视的列[姓名]), "姓名", "值", List.Sum),
    重命名的列 = Table.RenameColumns(已透视列,{{"Column1", "类别"}, {"属性", "姓名"}})
in
    重命名的列

步骤:
步骤一:加载数据源
file
步骤二:更改的类型
file
步骤三:转置
file
步骤四:提升标题
file
步骤五:更改的类型
file
步骤六:逆透视
file
步骤七:透视列
file
步骤八:重命名
file

案例二:
数据源:
file
结果:
file
代码:

let
    源 = Excel.CurrentWorkbook(){[Name="表4"]}[Content],
    更改的类型 = Table.TransformColumnTypes(源,{{"类别", type text}, {"姓名", type text}, {"a", Int64.Type}, {"b", Int64.Type}}),
    逆透视的列 = Table.UnpivotOtherColumns(更改的类型, {"类别", "姓名"}, "属性", "值"),
    已透视列 = Table.Pivot(逆透视的列, List.Distinct(逆透视的列[姓名]), "姓名", "值", List.Sum)
in
    已透视列

步骤截图:
file
file
file
file
file

案例3
透视和逆透视如何循环问题

file
结果1
file
结果2
file
代码:

let
    源 = Excel.CurrentWorkbook(){[Name="表6"]}[Content],
    更改的类型 = Table.TransformColumnTypes(源,{{"产品", type text}, {"1月", Int64.Type}, {"2月", Int64.Type}, {"3月", Int64.Type}, {"4月", Int64.Type}, {"5月", Int64.Type}, {"6月", Int64.Type}, {"7月", Int64.Type}, {"8月", Int64.Type}, {"9月", Int64.Type}, {"10月", Int64.Type}, {"11月", Int64.Type}, {"12月", Int64.Type}}),
    逆透视的列 = Table.UnpivotOtherColumns(更改的类型, {"产品"}, "月份", "值"),
    已透视列 = Table.Pivot(逆透视的列, List.Distinct(逆透视的列[产品]), "产品", "值", List.Sum),
    逆透视的列1 = Table.UnpivotOtherColumns(已透视列, {"月份"}, "产品", "值"),
    已透视列1 = Table.Pivot(逆透视的列1, List.Distinct(逆透视的列1[月份]), "月份", "值", List.Sum)
in
    已透视列1

步骤截图
file
file
file
file
file
file
好了都是些基础的