T-SQL Tuesday #86 : Sorting a Stacked Chart

Melissa Connors

Published On: January 10, 2017

Categories: SQL Server, T SQL Tuesday, Connect, PowerBI 0

This month's T-SQL Tuesday topic is "SQL Server Bugs & Enhancement Requests." My T-SQL Tuesday post is about a request for Power BI, which may be a little on the edge of SQL Server as far as T-SQL Tuesday goes. I want to talk about a limitation when sorting a Stacked Chart.

As I mentioned in my previous blog post, I started to play around with Power BI at the end of 2016. Once I was able to get most things working functionally, I wanted to make my dashboard appear and flow a certain way.

The Stacked Chart

First, I charted some important data about canines, which is why Power BI exists. OK, so neither of those statements are exactly or at all true, but I'm using canines for my example. Second, I decided on a "Stacked column chart" to display this wonderful data.

My Fancy Power BI K9 Report with Stacked ChartMy Fancy Power BI K9 Report with Stacked Chart

Third, I decided that I didn't like the "fox" canine type in the middle. I wanted the stack sorted from greatest value to smallest value. I played with the "Sort By" options in Power BI, however, those only shifted the order of the columns along the X-Axis (by total canine count or the Sample name), not the vertical values within each column.

Power BI Sort By OptionsPower BI Sort By Options

Therefore, when I change it from A-->Z sort to Z-->A sort, I get this:

Stacked Chart Sorted largest total count to smallest total countMy Fancy Power BI K9 Report Sorted Largest to Smallest Total Count

Currently, it's displaying the stacked column in alphabetical order from the bottom up (coyote/red on the bottom, fox/black in the middle, and wolf/gray on the top). I want the ability to display it by the count for each type, not the name. In this example, I want the order of coyote, wolf, and fox. I believed that there must be a way to control the order within a stacked column, so I clicked all over the UI and fired up the Google.

The Connect Item

Finally, I asked a coworker who knows much more about Power BI than I do, and he was familiar with this limitation. This led to me learning about the "Ability to sort the individual stacks within a stacked bar chart" enhancement idea and brings us back to the T-SQL Tuesday topic. You might have noticed that this isn't actually a Connect item. It is, however, a place where Microsoft accepts ideas for Power BI enhancements. If you'd like some control over how items are stacked in a column, please vote for this Power BI idea. It's a little thing, but it's always the small stuff, isn't it?

Thank you, Brent Ozar (b|t), for hosting this month's T-SQL Tuesday and providing us with a soapbox for our data-related woes.

Melissa is the Product Education Manager at SentryOne. Melissa has over a decade of experience with SQL Server through software performance and scalability testing, analysis and research projects, application development, and technical support.


Comments