我正在尝试从一列创建两个单独的列。我的成本类型列具有实际和预测为类型

发布于 2025-02-05 13:44:09 字数 204 浏览 3 评论 0原文

如上图所示,我试图将实际和预测分为列。是否有一种方法可以像图像中所示?

enter image description here

as shown in the image above, I am trying to separate actuals and forecast as columns. Is there a way to transform a table as shown in the image?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

贱贱哒 2025-02-12 13:44:09

它的过滤和组合。

使用列顶上的下拉列表来过滤“实际元素”的cost_types。删除cost_types列。将金额列重命名为实际

使用列在列上下拉下拉列表以过滤“预测”的cost_types。删除cost_types列。将金额列的重命名为预测

组合两个数据集

”“在此处输入图像说明”

示例代码:

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

#"Filtered Rows" = Table.SelectRows(Source, each ([cost type] = "actual")),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"cost type"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"amount", "actuals"}}),

#"Filtered Rows2" = Table.SelectRows(Source, each ([cost type] = "forecast")),
#"Removed Columns2" = Table.RemoveColumns(#"Filtered Rows2",{"cost type"}),
#"Renamed Columns2" = Table.RenameColumns(#"Removed Columns2",{{"amount", "forecast"}}),

combined = Table.Combine({#"Renamed Columns" , #"Renamed Columns2"})
in  combined

替代数据结构,这对我来说更有意义:

”

代码:

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"project id", type text}, {"title", type text}, {"manager", type text}, {"dept", type text}, {"Subproject id", type text}, {"effective date", type text}, {"cost type", type text}, {"amount", Int64.Type}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[#"cost type"]), "cost type", "amount", List.Sum)
in  #"Pivoted Column"

Its filtering and combining.

Use drop down atop the column to filter cost_types for "actuals". Remove cost_types column. Rename the amount column as actuals

Use drop down atop the column to filter cost_types for "forecast". Remove cost_types column. Rename the amount column as forecast

combine the two data sets

enter image description here

sample code:

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

#"Filtered Rows" = Table.SelectRows(Source, each ([cost type] = "actual")),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"cost type"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"amount", "actuals"}}),

#"Filtered Rows2" = Table.SelectRows(Source, each ([cost type] = "forecast")),
#"Removed Columns2" = Table.RemoveColumns(#"Filtered Rows2",{"cost type"}),
#"Renamed Columns2" = Table.RenameColumns(#"Removed Columns2",{{"amount", "forecast"}}),

combined = Table.Combine({#"Renamed Columns" , #"Renamed Columns2"})
in  combined

alternate data structure, which makes more sense to me:

enter image description here

code:

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"project id", type text}, {"title", type text}, {"manager", type text}, {"dept", type text}, {"Subproject id", type text}, {"effective date", type text}, {"cost type", type text}, {"amount", Int64.Type}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[#"cost type"]), "cost type", "amount", List.Sum)
in  #"Pivoted Column"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文