Forum Discussion

SamIsh's avatar
SamIsh
Frequent Visitor
1 year ago

Rearrange 100% Stacked Bar Legend order when utilising negative values. (Survey Data)

Hey! 
I have a bit of a conundrum. I have a 100% stacked bar graph in PowerBI that shows some dummy survey data. I want to order the legend in the format "Strongly Disagree," "Disagree," "Agree," and "Strongly Agree," but due to the negative values, PowerBI seems to sort the measures in the graphic oddly. 

 

To get the graphic looking correct, I have to swap "Disagree" and "Strongly Disagree" around in the "X-Axis" field, this in turn breaks the legend order.

I can "correct" the X-Axis order but this breaks the graphical order for some reason. 

The "Legend" option on the graphic isn't receptive to any field I have tested.

 

Any assitance would be brilliant! 

Best,
Sam

3 Replies

  • ajohnso2's avatar
    ajohnso2
    Icon for Solution Supplier rankSolution Supplier

    Within transform data create a new numeric column to sit alongside your descriptions.

    Description

    DescriptionSort Order
    Strongly Disagree1
    Disagree2
    Agree3
    Strongly Agree4

     

    Once this is done, from within the data view pane set the Order By on Description to use the numeric value of Sort order.

     

    Then within your visual, click the 3 dots (top right of visual) and set to sort by Description

    • SamIsh's avatar
      SamIsh
      Frequent Visitor

      Hey ajohnso2, 

      Thanks for your quick response; however, ordering by a numerical column isn't possible with measures. The measures are necessary to have the negative results to the left of the y-axis on a 100% graphic with survey responses.

      • ajohnso2's avatar
        ajohnso2
        Icon for Solution Supplier rankSolution Supplier

        If your descriptions are in their own dimension table (you can create this in power query if you dont have one). Join it to your fact data on description. You can then use the description from your new dimension table as the legend in your chart to make use of the sort order.

         

        Are you able to share your pbix?