Paul Turley's SQL Server BI Blog

sharing my experiences with the Microsoft data platform, SQL Server BI, Data Modeling, SSAS Design, Power Pivot, Power BI, SSRS Advanced Design, Power BI, Dashboards & Visualization since 2009

Menu

Skip to content
  • Home
  • My Books
  • Video Tutorials
  • Presentations
  • Training & Consulting Services
  • Visualizations
  • About/Bio
  • Paul’s Bio
  • Note to SPAMers

Tag Archives: Threshold line

Column Chart with Goal Threshold Line

March 11, 2010 by Paul Turley

7

Chart reports are an effective way to visualize data to show trends and comparisons in a way that can help the user get real meaning from numbers. However, chart data can be meaningless without context. This example will show you how to display a column chart with a goal line so users can easily understand whether charted values are above or below and acceptable threshold. I provide three versions of this report; a simple example using a SQL query to demonstrate the essentials, one with an MDX query and a copy of the latter with a parameterized threshold and dynamically colored columns to show data points above or below the goal.

This is a report design that you can almost do with standard report design features but it?s that last little step ? that last critical piece ? that takes a little creativity to solve. When I was first challenged to design this report for a consulting client, I knew that it could be done but I just wasn?t sure how. I grew up in Washington State in the 1970s with the legend of Bigfoot. For a while, there were Bigfoot sightings every week and everyone knew someone claimed to have seen Bigfoot (or had seen someone who knew someone who had claimed to have seen Bigfoot.) We knew he was out there in the remote wilderness but we weren?t sure where. This was a little like that ? the solution was out there and I just needed to find it.

This technique falls into a category that I need to give credit for before I mention it. Chris Hays, who is responsible for the Report Definition Language specification on the SSRS product team, coined the phrase ?sleazy hack? in the title of his blog site a few years ago. Owing to Chris for the definition, the report design technique showcased in this recipe is definitely in the sleazy hack category.

Product Versions

  • Reporting Services 2008

What You’ll Need

  • Column, area or line chart
  • Experience with VB expressions

Designing the Report

This solution is more about technique than complexity. The chart you see in Figure 1 has some simple design features you?d expect to be fairly easy to define but this is a little challenging to do right out of the box. In SSRS 2008, creating multi-series reports like this one, containing columns and a line, is standard fair. However, the natural behavior of all charts is that each column or line segment is plotted from the center of the data point along the axis. This means that since the line and columns in this chart have the same range of category (X-axis) values, the line would begin in the center of the left-most column and end in the center of the right-most column instead of running from edge to edge of the chart container. In fact, no matter what the minimum and maximum values are, the chart normally provides a margin of space on each side of the axis. You?ll see this and the resolution as we work through the report design.

 Chart Full Line 1

Figure 1

Let?s get started. The first bit of ?hack? is in the query. In order for the line to extend beyond the range of column center points, it must begin and end with lower and higher scale values than the respective column points. This means that we need to work some magic in the query and add two extra values to the scale.

1. Create a new report

2. Add a data source for the AdventureWorksDW2008 database.

3. Create a dataset and enter the following SQL script:

select

Category as CategoryGroup

, Qty

, Target

, RANK() over (order by OrderNum, Category) as OrderValue

from

(

select Null as Category, Null as Qty, 12000 as Target, 0 as OrderNum

union

select

pc.EnglishProductCategoryName as Category

, Sum(fis.OrderQuantity) as Qty

, 12000 as Target, 1 as OrderNum

from

FactInternetSales fis inner join DimProduct p

on fis.ProductKey=p.ProductKey

inner join DimProductSubcategory ps

on p.ProductSubcategoryKey=ps.ProductSubcategoryKey

inner join DimProductCategory pc

on ps.ProductCategoryKey=pc.ProductCategoryKey

group by pc.EnglishProductCategoryName

union

select Null as Category, Null as Qty, 12000 as Target, 2 as OrderNum

) as s;

Execute the query and view the results:

CategoryGroup City Target OrderValue
NULL NULL 12000 1
Accessories 36092 12000 2
Bikes 15205 12000 3
Clothing 9101 12000 4
NULL NULL 12000 5

Figure 2

You should notice that we have added two fictitious rows to the results on the first and last records, based on the OrderValue sort order. Notice also the lack of values for the CategoryGroup and Qty columns, but the Target column contains values in these rows. This provides the basis for the goal line to extend beyond the range of points plotted by the column chart.

Build the chart and define the groups and series data fields.

1. Add a new chart to the report body.

2. Choose a standard column chart type.

3. Drag and drop or select the OrderValue field in the Category axis.

4. Drag and drop or select the CategoryGroup field as a second field in the category axis.

5. Click the chart in the designer to show the data field and axis field drop zones.

6. Add the Qty and Target fields to the data fields drop zone to define the data series.

7. Right-click the Target field and change the chart type for this series to a Line chart.

8. Remove the axis labels.

Cosmetic changes can be applied as appropriate. These may include the line chart weight and color. The report in the designer should look similar to Figure 3.

Report design 2

Figure 3

Preview the report and compare the result to Figure 4. You?ll notice the empty columns for the OrderValue field values 1 and 5. Note how the line chart naturally extends from the center of first column position to the center of the last. Again, the requirement is for this line to extend from margin to margin.

fgXX04

Figure 4

Don?t worry about the axis labels for both of these groups. When we change the axis value range, the labels for inner group will disappear. Before we do this, we need to show the CategoryGroup field values on the outer group instead of the numbers:

1. In the Category axis fields, edit the OrderValue group properties.

2. In the Category Group Properties dialog, set the Label property to use the CategoryGroup field.

fgXX02

Figure 5

Now we?ll work our magic on the line chart margins?

To eliminate the extra space around the chart, we?ll set the left and right axis margin to be one-half of a scale value from the first and last column positions.

1. Right-click on the Category axis labels at the bottom of the chart and open the Axis Properties dialog.

2. Edit the axis scale Minimum property and set it to the following expression:

=MIN(Fields!OrderValue.Value) + 0.5

3. Edit the axis scale Maximum property and set it to the following expression:

=MAX(Fields!OrderValue.Value) – 0.5

4. Accept these changes and preview the report, comparing your results with Figure 6.

 

Preview 2

Figure 6

At this point, you have a working chart report with the essential features. The goal line, which is actually a line chart, extends from margin to margin. Even though we added extra values to the beginning and end of the axis range to make this work, now the columns fill the entire chart area.

Adding Dynamic Color

We can use a dynamic fill color to bring attention to series values that are above or below the goal line. Columns under the goal will be red and columns at or above the goal will be lime green. To enable this feature, follow these steps:

1. Click once on the chart to show the field drop zones.

2. Right-click the Qty field series and open the Series Properties dialog.

3. On the Fill page, set the Fill style property to Solid.

4. Next to the Color drop down, click the Expression button (fx) to open the Expression dialog.

5. Enter the following expression:

=IIF(Fields!Qty.Value < Fields!Target.Value, “Red”, “Lime”)

6. Close all dialogs and preview the report.

fgXX07

Figure 7

Charts in Reporting Services offer a lot of design flexibility and opportunities to customize the behavior and visual presentation of data. However, with these capabilities come a myriad of properties that can be a bit daunting to navigate and find in the design interface. This report design may not be quite as elusive as Bigfoot but it does solve a specific problem and provide real business value.

When exploring new features and design patterns, I find it useful to save versions of my chart reports in different stages of development. This way I can revert to a working state if I get myself into trouble. With some practice and perhaps a few late nights of experimentation, you will develop patterns that work best for your users and the data they need to visualize.

Share this:

  • Click to email this to a friend (Opens in new window)
  • Click to print (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on Reddit (Opens in new window)

Like this:

Like Loading...
Posted in SQL Syndication, SSRS Design. Tagged Column chart, Strip line, Threshold line

Post navigation

Credentials

930,374 total unique views.  Recent views:

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 4,004 other followers

Recent Posts

  • A Conversation with Ásgeir Gunnarsson about Power BI in the Enterprise
  • Setting up Power BI project Team Collaboration & Version Control
  • Next Level Power BI – M Language Basics
  • Chat with Donald Farmer at PASS Summit 2019
  • Next Level Power BI – SVG Databars
  • Next Level Power BI – SVG Symbols
  • So, I wrote a bedtime book now?!
  • Power Platform World Tour Vancouver Presentations
  • Power BI Project Good and Best Practices
  • Power BI Product Suggestion: Show Measure Dependencies

BI Industry BI Projects Business Analytics Microsoft BI Platform MVP Community PASS Power BI PowerPivot Power View Self-service BI SolidQ SQL Server SQLServerPedia SQL Server Pro Magazine SQL Syndication SSAS Administration SSAS Design SSRS Administration SSRS Design Tabular Models

Archives

  • December 2019 (1)
  • November 2019 (5)
  • October 2019 (1)
  • September 2019 (1)
  • August 2019 (2)
  • July 2019 (5)
  • May 2019 (1)
  • April 2019 (3)
  • March 2019 (1)
  • February 2019 (2)
  • December 2018 (3)
  • November 2018 (1)
  • October 2018 (1)
  • September 2018 (3)
  • July 2018 (5)
  • May 2018 (2)
  • April 2018 (2)
  • March 2018 (3)
  • February 2018 (3)
  • January 2018 (3)
  • December 2017 (3)
  • November 2017 (4)
  • October 2017 (1)
  • September 2017 (2)
  • August 2017 (1)
  • July 2017 (1)
  • June 2017 (4)
  • April 2017 (8)
  • March 2017 (1)
  • February 2017 (2)
  • January 2017 (8)
  • December 2016 (4)
  • November 2016 (3)
  • October 2016 (2)
  • September 2016 (1)
  • July 2016 (3)
  • June 2016 (3)
  • May 2016 (3)
  • March 2016 (6)
  • February 2016 (5)
  • January 2016 (2)
  • December 2015 (4)
  • November 2015 (3)
  • October 2015 (2)
  • September 2015 (2)
  • August 2015 (3)
  • July 2015 (6)
  • June 2015 (1)
  • May 2015 (5)
  • April 2015 (4)
  • March 2015 (1)
  • February 2015 (2)
  • January 2015 (4)
  • December 2014 (3)
  • November 2014 (1)
  • October 2014 (4)
  • September 2014 (1)
  • August 2014 (2)
  • July 2014 (5)
  • June 2014 (4)
  • May 2014 (2)
  • April 2014 (6)
  • March 2014 (3)
  • February 2014 (7)
  • January 2014 (5)
  • December 2013 (2)
  • November 2013 (1)
  • October 2013 (1)
  • September 2013 (2)
  • July 2013 (4)
  • June 2013 (5)
  • April 2013 (1)
  • March 2013 (4)
  • February 2013 (3)
  • January 2013 (1)
  • December 2012 (4)
  • November 2012 (4)
  • October 2012 (3)
  • September 2012 (3)
  • August 2012 (2)
  • July 2012 (2)
  • June 2012 (2)
  • May 2012 (3)
  • March 2012 (2)
  • February 2012 (3)
  • December 2011 (1)
  • November 2011 (3)
  • October 2011 (11)
  • September 2011 (7)
  • August 2011 (4)
  • July 2011 (2)
  • June 2011 (4)
  • May 2011 (5)
  • April 2011 (5)
  • March 2011 (4)
  • February 2011 (2)
  • January 2011 (4)
  • December 2010 (4)
  • November 2010 (4)
  • October 2010 (1)
  • September 2010 (1)
  • August 2010 (2)
  • June 2010 (1)
  • May 2010 (2)
  • April 2010 (1)
  • March 2010 (19)
  • December 2009 (1)
  • June 2009 (1)

Tag Cloud

Ad-hoc reporting Add columns Alternate row colors best practices BI Center of Excellence BI Conference Bill Gates Breakcrumb links Browser settings Business scorecard Checkbox in report Checkbox list Check mark Column chart Conditional formatting Conference presentation Conference review Conference session Datazen Date parameters DAX Drill-down Drill-through Dynamic column visibility European PASS Filter by user Greenbar report Hide columns KPI indicator Login prompt Manually starting subscription Master-detail report MDX datasets MDX queries Microsoft Architecture Journal Microsoft MVP Nested tables Parameterize Parameters PASS Conference PASS Summit PASS Summit 2017 Pop-up window; Java script Portland OR PowerPivot Power View Recipes Remove columns Repeating list report dependencies Report deployment Report navigation Report parameters Report recipe book Reports for MDX Return specific row Self-service reporting SolidQ SolidQ Journal SQL Saturday SQL Server community SQL Server MVP SSRS dynamic columns SSRS version control Start subscription Strip line Subscription Tabular report design TechEd Threshold line Top values User-related report content User authentication User prompted to login Wrox book
RSS
RSS Feed
Blog at WordPress.com.
loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.
%d bloggers like this: