Data => Get&Transform => From Table/Range或者From within sheet
当 PQ UI 打开时,导航到Home => Advanced Editor
记下代码第 2 行中的表名称。
用下面的M代码替换现有代码
将粘贴代码的第 2 行中的表名更改为您的“真实”表名
检查任何评论和Applied Steps窗口,以更好地理解算法和步骤
我们选择前三列并取消旋转其余列
然后在 Date 列上以 Values 列作为值
AND使用高级“无聚合”集
然后添加Diff列
M代码
let
//change table name in next line to your actual name in your workbook
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
//set the data types
#"Changed Type" = Table.TransformColumnTypes(Source,{
{"Emp. Code", Int64.Type}, {"Name", type text}, {"ProcessDate", type date},
{"EARNED MEDICAL", Int64.Type},
{"EARNED CONVEYANCE", Int64.Type},
{"NetPay", Currency.Type},
{"ESI", Currency.Type},
{"Income Tax", Currency.Type},
{"PF Amount", Currency.Type},
{"TOTAL DEDUCTION", Currency.Type}}),
//Select the first three columns and Unpivot Other Columns
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type",
{"Emp. Code", "Name", "ProcessDate"}, "Attribute", "Value"),
//Pivot on the Date column with Values = the Values column
#"Pivoted Column" = Table.Pivot(
Table.TransformColumnTypes(#"Unpivoted Other Columns", {{"ProcessDate", type text}}, "en-US"),
List.Distinct(Table.TransformColumnTypes(#"Unpivoted Other Columns",
{{"ProcessDate", type text}}, "en-US")[ProcessDate]),
"ProcessDate", "Value"),
//Add the Diff column
#"Added Custom" = Table.AddColumn(#"Pivoted Column", "Diff", each [#"3/1/2022"]-[#"2/1/2022"], Currency.Type)
in
#"Added Custom"
您可以使用
Power Query
Windows Excel 2010+ 和 Office 365 Excel中的 获得所需的输出在原始表格中选择一些单元格
Data => Get&Transform => From Table/Range
或者From within sheet
当 PQ UI 打开时,导航到
Home => Advanced Editor
记下代码第 2 行中的表名称。
用下面的M代码替换现有代码
将粘贴代码的第 2 行中的表名更改为您的“真实”表名
检查任何评论和
Applied Steps
窗口,以更好地理解算法和步骤Diff
列M代码
数据
结果