Forum Discussion

jvirgi's avatar
jvirgi
Icon for Helper III rankHelper III
6 years ago
Solved

Creating a diverging stacked bar chart to show sentiment

I was trying to create a diverging stacked bar chart to show the %'s of sentiment on data.  I can't figure out an easy way to do this in power BI.   Here is a sample set of data: Sport TEXT Se...
  • parry2k's avatar
    parry2k
    6 years ago

    jvirgi add following 3 measure, of course, these can be done in one measure but I like to break up the measure for easy debugging and maintenance.

     

    Would appreciate Kudos 🙂 if my solution helped.

     

    Base Count = COUNTROWS ( 'Table' )
    
    Sentiment Count = IF ( SELECTEDVALUE( 'Table'[Sentiment] ) = "Negative", -1, 1 ) * [Base Count]
    
    % Sentiment = DIVIDE ( [Sentiment Count], CALCULATE ( [Base Count], ALLSELECTED( 'Table'[Sentiment] ) ) )

     

    To visualize do the following and on format pane, you can change the colors