An indicator pulls one piece of data from your SQL Server database and puts it in a report to indicate whether it is positive or negative for your business, based on a scale you set up in the report. Adding indicators to a report can help you make sound business decisions. Learn how to create indicators in your report with this online video.
- View Offline
We've been working our way through the options on the Insert tab, and the next two up in the Data Visualization section are Gauges and Indicators. I'm going to talk about both of these at the same time because they're very similar to each other. They're both simpler than charts in that they typically just display one data point. But they're also configured to tell us whether that data point is good or bad or how far along a scale it's supposed to be. So, I have a blank report here with a data source pointing to the regular AdventureWorks database.
I'm going to go and get us some data. So creating a new dataset, I'll call this one TerritoryInfo, and jumping into Query Designer, I'm going to start drilling down into the Tables section, and I've got a SalesTerritory table-- I don't think we've used this one yet--where I will get the name of the territory, the Sales Year To Date, and the SalesLastYear. I'll just go ahead and run this query to see if this might be useful data for us.
It looks about right. We're getting these different regions: SalesYTD, SalesLastYear. There is not a ridiculous amount of data, so it will be good to have on a table. Click OK. That's my dataset. Now, while we can add gauges and indicators completely independently, like sparklines, they're very commonly seen on a table or a matrix. So I'm going to go ahead and insert a new table based on that dataset I just created. And all of these columns, I'm just going to put in the Values section.
I'm doing no grouping whatsoever, either up and down or left to right. Clicking Next, I'll just go right past the layout, Next again, and this time I'll pick Slate. Run this, just to test everything looks okay. We are getting that information out. I don't really need the four decimal places here, and I'd like to make it apparent this is a currency amount. So I'll jump back into Design view, just select in there to grab that text box, and I can Shift+Select to get the second one, and change both of the formatting here to Currency, and then click the button to decrease the decimal point until it grays completely out so that we're not showing any decimal numbers at all. That looks good.
Again, what we're trying to do here is get the idea. We could have a massive amount of numbers, and I'd like to be able to quickly scan them to see if something is good or bad. What I'm going to do is add a new column to this table and put an indicator in it. So to add a new column, I'll just click somewhere in the table here to make the gray handles appear, then grab this last column, right-click the gray area, and insert a new column to the right. And I'm going to insert an indicator right here in this cell.
We want it to be the same cell that we're actually seeing the name of the territory on, or the sum of SalesLastYear. Like sparklines, it's very sensitive to where you place indicators. We don't want to put them in the header row. So, up to the Insert tab, click Indicator once, down into the cell I'm interested in, and click again. Our Indicator Type window appears. All of these are configured the same way. They're just a different graphical look and feel. You can change these later after the fact if you want to.
I'm going to pick something basic, such as this set of three shapes here-- the traffic light idea--and click OK. We see that ended in the column. Well, what happens if we run this? Absolutely nothing, because that indicator has no idea what it's meant to display. Back into Design view, I'm going to select it. Selecting indicators and gauges can sometimes be tricky because they are wheels within wheels. There is a couple of things we have to be careful of when clicking around. So, if I click again, I'll eventually select this indicator.
I'll see this little Gauge Data window appear, because an indicator is a gauge. That's why we're doing both of these at the same time. And it has this dropdown window that's very similar to working with a chart or a sparkline. Right now, it's asking for one value. It's not asking for groups. It's not asking for series. It's just saying, hey, what number am I supposed to represent? Well, I'm interested in this being a graphical representation of the sales year to date, so I'm going to drag that over here and drop it in.
Go ahead and run it. Well now we're getting indicators, although the question might be, what is this actually meant to be representing? We've got some green, some red, some yellow. An indicator is always fueled by one single value, but it needs to have some rules about whether that value is good or bad. Now, when you drag one on, it defaults to a percentage rule. The values of the top 33% are in green, the middle in yellow, the bottom in red. Now, it doesn't mean you'll always see equal amounts of red, green, and yellow, as the numbers that these are representing--which is my SalesYTD--aren't distributed exactly equally, so only two of them--the most high numbers--might actually represent 33% of the total.
Having said that, a pure percentage rule isn't what you want most of the time anyway, so let's see how to change that. Drop back into Design view. I'll highlight this, clicking the Gauge again till this appears. We can't do anything really more here, but I can right-click and I've got an option called Indicator Properties. If you don't get the option Indicator Properties, make sure you're clicking in the right place, because with that open, I have an option for Value and States, and this is where all the magic happens for an indicator.
It's how you determine which indicator actually shows up. First, it's saying okay, I'm displaying the value of sales year to date for each row. That's fine, no problem there. But the next option is, am I displaying a percentage or am I based on a specific numeric value? Well I'm going to switch to a numeric value here. And all I want to do is make this indicator quickly represent whether this year's sales have already beaten last year's sales. So in fact, I don't even need the yellow indicator here, so I'm going to highlight an area of that row and just delete it.
And in this section I describe the rules. Why should it show up in red, why should it show up in green? I'm going to say if sales year to date have been anything from 0 all the way up to the same as sales last year, then it's red. If it's from sales last year plus one dollar, or anything above that, then it can show up in green. So, 0 is fine as a starting point, but 33 is not good as an ending point. I'll just delete that, and I'm clicking the little expression builder here. So it's asking for an expression for the end value, and all I want to do is jump to my Fields section for this dataset and say I'm interested in this being more than sales last year. Click OK.
Next, I have to describe the rules for green. Well, it's not going to start at 66, so I click the expression builder. And I want the button to the right-hand side, because the one to the left is controlling a dynamic color. That's not what I want here. So click this. What I'm going to do here again is we're going from sales last year and then I just enter in plus 1, because we want to be beat it. Click OK. I don't want that one to have an end. As long as it's greater than last year's sales plus one dollar, it can show up in green.
What you'll also find over here is the ability to change the icon. We have a whole list of them, so if you want to change it, here's how you do it. In fact, I might even change that to a smiley face. Click OK and run. Now we have the indicator showing up as long as the sales year to date have beaten sales last year. Very simple to implement!
Note: These tutorials are applicable to both the 2008 and 2012 versions of SQL Server.
- Understanding the elements of a report
- Grouping table regions
- Joining data from multiple tables
- Displaying data in a matrix
- Customizing report parameters
- Filtering and sorting data
- Creating charts
- Adding sparklines and data bars
- Creating at-a-glance reports with indicators
- Using Maps in Reporting Services
- Configuring report security
- Printing and exporting reports