简体   繁体   English

power bi 如何计算多列的安全/风险值

[英]power bi how to count Safe / On Risk value for multi columns

how to count Safe / On Risk value for multi columns and make Pie chart for all columns如何计算多列的安全/风险值并为所有列制作饼图

the target is to calculate how many (Safe) and how many (On Risk) in all columns目标是计算所有列中有多少(安全)和多少(风险)

example例子

在此处输入图片说明

在此处输入图片说明

In Power Query Editor , create a new table using this below code-Power Query Editor 中,使用以下代码创建一个新表 -

Please replace your_table_name in this below code with your original Table name .请将以下代码中的your_table_name替换为您的原始表名

let
    Source = your_table_name,
    #"Removed Other Columns" = Table.SelectColumns(Source,{"Helmet", "Goggels", "Shoes", "Gloves"}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Removed Other Columns", {}, "Attribute", "Value"),
    #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Columns",{"Attribute"}),
    #"Grouped Rows" = Table.Group(#"Removed Columns", {"Value"}, {{"Count", each Table.RowCount(_), Int64.Type}})
in
    #"Grouped Rows"

**Keeping Location in the result set"- **在结果集中保留位置”-

let Source = your_table_name,
    #"Removed Other Columns" = Table.SelectColumns(Source,{"Location", "Helmet", "Goggels", "Shoes", "Gloves"}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Removed Other Columns", {"Location"}, "Attribute", "Value"),
    #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Columns",{"Attribute"}),
    #"Grouped Rows" = Table.Group(#"Removed Columns", {"Location", "Value"}, {{"Count", each Table.RowCount(_), Int64.Type}})
in
    #"Grouped Rows"

Output will be as below-输出将如下-

在此处输入图片说明

Output with location -带位置的输出-

在此处输入图片说明

Now you can create your Pie Chart using this new table and the final output will be as below-现在您可以使用这个新表创建饼图,最终输出如下-

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM