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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

deldersveld

Creating Slopegraphs in Power BI

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