Forum Discussion

kopytko95's avatar
kopytko95
Frequent Visitor
2 years ago

Dynamic legend on bar chart doesn't sort categories properly when switching between selections

Okay, so i have dynamic legend with three columns/categories (one is text, two of them are numbers, 0-10 and 1-16 respectively and they have their own tables). There's parameter on the slicer, so whichever category i choose, it's on the Y axis of bar chart.
What is my problem - one of the numeric ones automatically sorts from 0 to 10 from left to right, while the other one autoamtically sorts by values.
I can manually choose to have it sorted by category, ascending instead of values, but when i do the switch on the slicer and switch back, it's again sorted by the values.
What i noticed, is that on the category that works well, when i open sorting menu (three dots -> sort axis), there is no check on neither category nor value, but on the other the check is initially always on values.

Any idea how to fix it? 

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi kopytko95 ,
    Based on your description, I can understand that you want to sort a bar chart with a fixed order of x and y axes. In Power bi, the initial sorting of the axes is usually numerical descending and alphabetical descending. If you change the data on an axis, it will be initialized. Also, you can only sort the bars according to one axis, otherwise the other axes will be affected.
    You can refer to these two documents
    Sort one column by another column in Power BI - Power BI | Microsoft Learn
    Change how a chart is sorted in a report - Power BI | Microsoft Learn

    Best regards,
    Albert He

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

  • kopytko95's avatar
    kopytko95
    Frequent Visitor

    One of the fields was sorted by some other (index) column and worked fine, and the one working badly was sorted by itself only which apparently triggered some switch in there (so the sort everytime was by the value) . I changed the field so it's by default sorted by some other column from the table which caused so it doesnt switch to sorting by value everytime i change selection.