Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Bar Chart with multiple bars plotted from separate columns

 
First post here and I've tried searching a few things and can't find anything similar enough to help on this one.  Thank you for all your help so far!

 

I have a sample table below which looks like this:

 

 

ID#Test1Test2

1

10 
200 
300 
400 
500 
601 
711 
810 
910 
1000 
1111 
1210 
1300 
1401 
1511 

 

 I am looking to create a bar chart that would show the number of 1s in test 1 and test 2, I also need to display (ideally stacked/clustered) the number of positive results for test 2 where test 1 is negative. So the x axis of the chart would show Test1, Test2, with 3 bars; the values would be the count of test1 column, count of test 2, count of test 2 where test 1 is 0. I can make all these columns in my table without issue, i cannot plot each column together on one plot- PBi seems to plot all combinations of the columns along the x axis when i try to add them all to a bar chart:

 

(my acutal table has some blanks)

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

     

    1. Unpivot the [test 1] and [test 2] in powerquery editor.

    2. the please create 3 measures.

    count = DISTINCTCOUNT('Table'[ID#])
    number of 1s = CALCULATE(DISTINCTCOUNT('Table'[ID#]), 'Table'[Value] = 1)
    count of test 2 where test 1 is 0 = CALCULATE( DISTINCTCOUNT( 'Table'[ID#]),'Table'[Attribute] = "Test1" && 'Table'[Value] = 1 )

    result.

     

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    1. Unpivot the [test 1] and [test 2] in powerquery editor.

    2. the please create 3 measures.

    count = DISTINCTCOUNT('Table'[ID#])
    number of 1s = CALCULATE(DISTINCTCOUNT('Table'[ID#]), 'Table'[Value] = 1)
    count of test 2 where test 1 is 0 = CALCULATE( DISTINCTCOUNT( 'Table'[ID#]),'Table'[Attribute] = "Test1" && 'Table'[Value] = 1 )

    result.

     

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum