Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
afaherty
Helper IV
Helper IV

"Sort By Column" changes stacked bar chart (DAX Related)

Hello,

I am running into a strange issue.  For my stacked bar chart below, I want to change the order in the visual so that "N/A" is last.

 

afaherty_0-1641410894382.png

 

I tried this 2 ways:

1.)  Created a new table of the legend items above, with a column for "order."  I then created a new column in the original data table using RELATED to pull in the order into the original data table.

2.)  Inserted a new conditional column, assigning each legend item an order number (consistently = 1, inconsistely = 2, etc).

 

Both of these solutions caused this to happen once I did the whole "Sort By Column" thing:

 

afaherty_1-1641411015238.png

 

Google cant seem to help.  Anyone have any ideas? Thanks everyone!

 

 

1 ACCEPTED SOLUTION

@ValtteriN 

Sure thing, the answer is that you need to adjust your measure.  Here's more info on how to do it:   https://blog.crossjoin.co.uk/2015/12/15/power-bi-desktop-sort-by-column-and-dax-calculations-that-us...

View solution in original post

5 REPLIES 5
ValtteriN
Super User
Super User

Hi,

I am having trouble re-creating your issue. The only explanation that came to my mind is that the sort is somehow messing with your calculation logic (though I can't fathom why). In my test data I built a relation between the table and sort table and used related and used RELATED to get the sort column. Then I sorted the category table's category using this sort column and everything works fine:

ValtteriN_0-1641423795053.pngValtteriN_1-1641423806631.png

 

Could you provide some more information on your problem?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ValtteriN I found another post describing exactly what I am experiencing, and I was able to fix my issue!

 

https://community.powerbi.com/t5/Desktop/Sort-By-Column-changes-the-Measure-results/m-p/91258 

Hi,

That's great! I would be good if you post your solution to this dicussion and mark it as a solution so that people will find the answer easier in the future.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ValtteriN 

Sure thing, the answer is that you need to adjust your measure.  Here's more info on how to do it:   https://blog.crossjoin.co.uk/2015/12/15/power-bi-desktop-sort-by-column-and-dax-calculations-that-us...

@ValtteriN 

Thank you for your help!  Here is a file of example data and I am experiencing the same behavior in this example data.  When I sort "Survey Question" by "Survey Question Sort," then all of the percentages on my stacked bar chart change to 100%.  If I sort "Survey Question" by itself, then this does not happen and the percentages are all correct.

 

Example File - Sort/Stacked Bar Chart Problem 

 

(I wish I could just attach it right here to this post but I don't have that option - I think it's because I'm still a bit of a newbie).

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors