如何旋转数据表中的多个列并根据 Power BI 中的二项式计数结果创建条形图?

How do I pivot mutliple columns in a datasheet and create a bar chart off the results from the binomial count in Power BI?

我有一个看起来像

的数据集
        Baseball|Basketball|FootBall|Soccer|State
Player 1       1           0        0     1    NY
Player 2       1           1        0     0    CA
Player 3       1           1        1     1    NY
Player 4       0           0        0     1    MA

我想在我的仪表板中创建一个图表或工作表来显示

Baseball   3
Basketball 2
Football   1
Soccer     3

也让它是动态的,这样如果我将过滤器更改为 CA 它会调整

Baseball    1
Basektball  1
Football    0 
Soccer      0

根据您的数据:

在 Power 查询中,您需要 select Baseball、Basketball、Football、Soccer 列和 select Unpivot 选项,它应该会为您提供类似这样的内容,其中两个新列 'attributes' 和 'value'

我重命名了属性 'Sports'

完成后,您可以创建一个基本度量

Sports Total = SUM('Table'[Value]) 

然后您可以根据自己的喜好对数据进行切片和切块