Power Bi-在高级编辑器中将计算添加到Group by



我正在使用PowerBi,而且有些新。我使用Power Bi Query Editor中的Group by函数创建了一个表。在按分组中,我将按类别对总持续时间(分钟(进行汇总。我想得到以小时为单位的总持续时间。是否可以除以60,通过高级编辑器获得小时数。下面是高级编辑器代码。

let
Source = #"Data",
#"Grouped Rows" = Table.Group(Source, {"category"}, {{"Total Minutes", each List.Sum([duration_in_min]), type nullable number}}),
#"Filtered Rows" = Table.SelectRows(#"Grouped Rows", each ([category] <> null))
in
#"Filtered Rows"

当然,您可以使用计算总小时数,而不是总分钟数

#"Grouped Rows" = Table.Group(Source, {"category"}, {{"Total Minutes", each List.Sum([duration_in_min]) / 60, type nullable number}}),

或者创建一个新列Total Hours,这样您的查询将类似于以下内容:

let
Source = Data,
#"Grouped Rows" = Table.Group(Source, {"category"}, {{"Total Minutes", each List.Sum([duration_in_min]), type nullable number}}),
#"Filtered Rows" = Table.SelectRows(#"Grouped Rows", each ([category] <> null)),
#"Added Total Hours" = Table.AddColumn(#"Filtered Rows", "Total Hours", each [Total Minutes]/60)
in
#"Added Total Hours"

最新更新