Creating Slopegraphs in Power BI

by deldersveld on ‎05-22-2017 09:21 AM

Slopegraphs are a great way to judge the rate and magnitude of change by looking at the steepness of a line’s slope. With a slopegraph, it is also easier to discern how different elements or categories trend compared to others. This type of chart was initially introduced as a Table Graphic by Edward Tufte in his book The Visual Display of Quantitative Information

 

Slopegraph Sample

 

The good news for Power BI users is that a Slopegraph is simply a specialized version of the Line Chart. If your data is formatted the proper way either at the source or using the Query Editor, it’s easy to build a Slopegraph in Power BI either from the ground up or by using filters.

 

From a data perspective, Power BI’s line chart works best using the following format. If your source data is already shaped like the following example, you can bring it in and start creating a visual.

 

00-IdealData

 

In many cases though, you might start with source data that has your slope numbers in two columns instead of one. In this case, you can reshape the data easily using the Query Editor.

 

01-InitialData

 

With data that appears like the sample above, connect to your source and import it into Power BI. Next, within the Query Editor, highlight the Initial Value and Final Value columns, go to the Transform tab, and select Unpivot Columns.

 

02-Unpivot

 

Unpivoting the data consolidates it from two value columns to one by moving the second column of values to an additional row. If your data already comes from the source in this format, it is even better since you can skip the unpivot step. Once your data appears in the ideal format, Close and Apply to start working with it on the report canvas.

 

03-AfterUnpivot

 

Add a Line Chart to your report, then place the Attribute field on the Axis, the Category on Legend, and the Value on Values.

 

04-LineChartSetup

 

Your report should show a visual similar to the following one.

 

05-NeedToSort

 

Tip: Do not use too many categories. Since Power BI relies on the color legend or tooltip to identify categories rather than a text label, a crowded chart might lead to a confused audience.

 

You may have noticed that in my example, the Final Value appears to the left of Initial Value due to the axis sorting alphabetically. If you need to change that based on your attribute labels, click […] in the top right corner of the visual and select Sort By Attribute.

 

06-Sort

 

After sorting, the sample slopegraph appears as anticipated, with the visual showing the progression from Initial Value on the left to Final Value on the right.

 

07-UnformattedChart

 

From here, it is all formatting. The final visual appears below. To get there, go to Format, then:

  • Disable the Y Axis
  • Enable Data Labels
  • Change data colors, label size, and line stroke width as desired

 

08-FinalChart

 

In addition, it is possible to transform a standard line chart with many values along the x axis and turn it into a slopegraph using Filters.

 

The sample slopegraph at the beginning of this article is actually a line chart with data that spans many different years. With a filter applied to narrow the date range to two values only, however, it becomes a slopegraph.

 

10-UnfilteredLineChart

 

09-FilteredLineChart

 

Simple, right? For the slopegraph, there are no DAX formulas or fancy workarounds. You can either start with a slopegraph in mind and use a dataset targeted to it, or you can back your way into one using filters on your line chart.

 

 

David Eldersveld blogs regularly on Power BI at dataveld.wordpress.com.

Comments
by MuqadderIqbal Frequent Visitor
on ‎05-22-2017 03:34 PM

Very handy tip.

by deldersveld
on ‎05-22-2017 04:43 PM

Thanks!

by yoshihirok Member
on ‎06-05-2017 07:29 PM

Nice,

 

Simple is more message.

 

Regards,

Yoshihiro Kawabata

by deldersveld
on ‎06-06-2017 01:52 PM

Thank you!

by iDataDrew Member
on ‎07-18-2017 11:48 AM

I've attempted this in the past, but failed.  Thanks for sharing!  I love slope graphs.