user35131
user35131

Reputation: 1134

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

I have a dataset that looks like

        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

I would like to create a graph or worksheet in my dashboard that would show

Baseball   3
Basketball 2
Football   1
Soccer     3

Also have it be dynamic so that if i change the filter to CA it would adjust

Baseball    1
Basektball  1
Football    0 
Soccer      0

Upvotes: 0

Views: 55

Answers (1)

Jon
Jon

Reputation: 4967

With your data: enter image description here

In Power query, you need to select the columns Baseball, Basketball, Football, Soccer, and select the Unpivot option, which should give you something like this, with two new columns 'attributes' and 'value' enter image description here

I've renamed attributes 'Sports'

Once you have done that, you can create a basic measure

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

You can then slice and dice the data by whatever you like enter image description here

Upvotes: 2

Related Questions