5 Replies Latest reply on Jul 31, 2018 3:57 AM by JP Kelly

    Ranking in Stacked Bar Chart

    JP Kelly

      Hi All,

       

      Complete Tableau novice here, battling with something which is probably (and hopefully) painfully obvious to the community and therefore easy to solve!

       

      I'm making a stacked bar chart (see screenshot 1) and want to include the rank for each row (e.g. Ellis would be 1, Cavell would be 2, and so forth). I can do this using a RANK_DENSE calculation but it only works if it's a regular bar graph, i.e. without the additional details of "course" or "title/chapter/article" (see screenshot 2).

       

      Hopefully I've provided enough info here - if not, ask away!

       

      Thanks in advance

       

      Screenshot 1:

      Stacked Bar Chart Ranking.jpeg

      Screenshot 2:

      Bar Chart Ranking.jpeg

        • 1. Re: Ranking in Stacked Bar Chart
          JP Kelly

          Before anyone points this out, I've also just realised I should really be using RANK rather than RANK_DENSE...

          • 2. Re: Ranking in Stacked Bar Chart
            Adam.Cogswell

            Hi JP, check out my attached example. I used Index instead of Rank, and by right clicking on the Index pill, and clicking "edit table calculations", you can get some finer control. I set it to specific dimensions, checked both dimensions (the one on rows and the one on color), and then changed the "at the level" setting to be state. Hope this helps!

            • 3. Re: Ranking in Stacked Bar Chart
              JP Kelly

              Hi Adam,

               

              Thanks for the reply - this has been a huge help! Using Index I'm (almost) able to get the desired results. I say almost, because index simply assigns a number to each row, rather than ranks each row(s). In the example below (where I've split the data into two categories: essential [orange] and recommended [green]) Ellis and Bordwell both have a total of 25. However, rather than both being ranked joint 2nd, with the subsequent entry being ranked 4th, they are simply indexed as 2nd and 3rd.

               

              Bar Chart Index.jpeg

               

              If I try to use the Rank function, all **** breaks loose (FYI, the rank function works perfectly well if I don't add additional categories to my visualisation, as in the second screenshot in my original post)! Even when I follow the same procedure of editing the calculation for the Rank function to compute using "specific dimensions", the resulting visualisation is still broken down and ranked into smaller sub-categories (as in the image below).

               

              Bar Chart Rank.jpeg

               

              Any thoughts?

              • 4. Re: Ranking in Stacked Bar Chart
                Adam.Cogswell

                Ahh I see. That's tougher. Instead of using index or fiddling with the table calc settings, I created a separate Rank calculated field that calculates a rank of a level-of-detail expression. The LoD expression excludes the color dimension from the aggregation, so we get a total per state, instead of per state and color dimension. Hope this makes sense!

                • 5. Re: Ranking in Stacked Bar Chart
                  JP Kelly

                  Thanks Adam, this is definitely an improvement. I'm still having a rather bizarre issue in that anything ranked below 20 is split into the two different colour dimensions (see screenshot below). I can't figure out for the life of me why this is happening! Could it be because I created a combined group based on that dimension? Originally there were four categories: essential, further, recommended and null. I combined these into two: essential and recommended (the latter being a combination of further, recommended and null). 

                   

                  The other issue I'm still having is that as soon as I want to add another dimension as an additional detail (e.g. "course") it messes up the entire bar chart. What I want to be able to do is to have something like the example you sent, but with the added feature that when a user hovers over each coloured dimension (in my case "essential" (orange) and "recommended" (green) readings) it reveals another layer(s) of details, i.e. the course on which that reading has been assigned. In other words, I want each of the colour bars broken up into smaller pieces that correspond to another dimension (namely "course").

                   

                  I really appreciate your help with this so far but I think I may have just reached the point at which I might just give up - unless of course there is an easy solution! It really surprises me that there isn't a feature in Tableau which will just assign a numeric label to each row based on the total sum of said row. Or perhaps there is!...

                   

                  Rank v2.jpeg