How To: Using Ranks to Create Slope Graphs in Tableau

10/29/2015 Matt Chambers 7 Comments




I originally learned how to create slope graphs in Tableau using Andy Kriebel's excellent tutorial. Andy's tutorial details how to use the rank function in Excel to prepare your data before building the slope graph in Tableau.  However, I wanted to build a slope graph for my Iron Viz dashboard, and I was not able to modify or transform the source data as I was given a .twbx file with an extract.

Tableau's rank function to the rescue!  Using the rank function, we are able to build a slope chart without having to do any transformation on our data.  Let's take a look at how it's done.

Step 1: Create a calculated field for the first measure we want to rank.  In this case, I am using rank_unique so that it doesn't assign the same rank to different values.

Step 2: Create another calculated field for the second measure we want to rank.

Step 3: add a dimension to the detail for the ranks to compute by.


Step 4: Drag the pill that you want on the right side of the slope graph to the rows, and then compute using the dimension you placed on the detail.


Step 5: Drag the pill you want on the left side of the slope graph to the side of the first stacked bar so that you see the two bars side by side.  Release the pill there.

Step 6: Make sure both measures are being computed using the dimension you specified for ranking.


Step 7: Simply change the marks to line and you have your slope graph!

Step 8: Add a measure to the label and choose "Line Ends" with the start and end of the line labeled.

Step 9: Drag a pill to the color.  In this case, I am using the Z-Score of the difference of the ranks, but you could easily substitute with just the difference of the ranks.

I hope you find this useful and an easier method than transforming the data with Excel.  Feel free to comment with any questions.


7 comments:

  1. thanks for the sharing...Can you post your dataset? or how can i find it?

    ReplyDelete
    Replies
    1. Hi, you can download the workbook here:

      https://public.tableau.com/profile/matt.chambers#!/vizhome/ReadAllAboutIt-BiasintheMedia-IronViz/ReadAllAboutIt-IronViz

      Delete
  2. This is a great post...very informative. I've been meaning to look into creating slope graphs in Tableau and this article is very easy to follow. Good work!

    ReplyDelete
    Replies
    1. Thanks Chris! I'm glad it helped.

      Delete
  3. You can find some more diagram examples of slopes in creately diagram community.

    ReplyDelete
  4. Hello Everyone, i am DAVID HILL MILLA now living in FLORIDA. I am SINGLE DAD, at the moment, two children and I was struck on the financial situation and need to refinance and pay for my son's medical bills and school fees. I tried looking for different loan lending companies and private corporation but never got a loan from them, and most banks reduced their credit. But as God would have it, I was introduced to the private loan lender JULIA NAVARO CEO NAVARO LOAN COMPANY and I got the loan amount ($553,760 USD), and today I am a business owner, and the kids are doing well at the moment. So, my dear friends, if you need to contact referring to all the companies that provide the loan at low interest rate of 2% and better repayment plans and schedules, please contact (JULIA NAVARO) at Navaroloancompany@yahoo.com. I'm so happy now, and I decided to let people know more about it, she offers all kinds of loans to individuals and company, and I want God to bless her. You can contact the company via e-mail (Navaroloancompany@yahoo.com)....

    ReplyDelete