Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
Discover how to create, manage, and deliver interactive reports—not just to print, but to dynamically explore enterprise-level data—with Reporting Services in SQL Server. In this course, author Simon Allardice concentrates on using Report Builder to build and format reports from a variety of data sources, but also shows how to perform basic administration tasks such as granting user access and organizing reports in the Report Manager. Plus, learn how to add interactive sorting and filtering functionality to your reports, and create column and pie charts to better express your data.
Note: These tutorials are applicable to both the 2008 and 2012 versions of SQL Server.
Everybody knows the pie chart, but not everyone thinks about the right time to use it and the right data to use it with. Pie charts are most useful when you have just a handful of data points to compare. The recommendation is seven or less. But that doesn't mean that you would always expect these data points to be waiting in the database for you. No, you often need to construct them by joining tables and applying functions. And I am going to do that right now. Again, for time's sake, I have a blank report here where I have added a data source pointing to the regular AdventureWorks database. That's it.
I am going to create a dataset here. And this is going to be information about customer regions. Jumping into the Query Designer for this, I am going to drill down again into the Sales area and into the Views area. There is a useful view in the AdventureWorks sample database called vIndividualCustomer. I am just going to select a few columns in this, BusinessEntity, FirstName, EmailAddress, and CountryRegionName. I'll actually end up with fewer than these in just a moment; I just want to show what happens when we run this query.
So you got BusinessEntityID. That seems to be some kind of key. We've got the FirstName, we've got the EmailAddress, and then we've got this CountryRegionName area: United States, France, Australia, Canada. There might be a few others. As I keep scrolling, I get more and more data. There is a fair amount of data that I could find in this AdventureWorks database. But let's say my business problem here is I really want to find out how many of our customers come from the US as opposed to Australia. What is the most popular place for us? Well, I can do that very easily.
I am going to do this in the query itself. Here's what I'll do first: unselect everything except BusinessEntityID and Region. So again, if I just run the query, that's all I am really getting here: a column and the region. It doesn't really matter which column I ended up with here. I just needed something, because with these two selected, what I am going to do is go into my grouping area here with my selected fields, highlight CountryRegionName, come over to the aggregate section, and say I want to group by the CountryRegionName.
It will also change BusinessEntity to group by, but I don't want to group that; I want to count it. I am not summing; I am not totaling or averaging. I am simply saying for each specific distinct country and region, how many columns do you have? So I could be counting the BusinessEntityID column or I could be counting the LastName column or the EmailAddress column. It really doesn't matter, as long as I am grouping by the country and region. Now if I go ahead and run the query, this is what I get back: the CountryRegionName and an account of columns that have been returned for that.
This is perfect kind of data for a pie chart. We don't have a lot of data points. In this case, it's really six different categories with six different values. So I am going to go ahead and use this. I am done with the dataset. Click OK. Give our report a title and jump over to Insert. Instead of using the wizard, I am just going to say Insert Chart. As soon as you do that, the crosshairs of your cursor change, so I am just going to come down and drag this. I can drag it a little lower than the page itself, and it should expand to fit.
Then we get the window that asks us what type is this? Again, you can change from one to the other after you've configured them, but I am just going to go ahead with the basic pie chart that's in the Shape section, and click OK. Now, right now there is absolutely no connection between this chart and the dataset that I just defined. I need to make those all myself because I didn't use the wizard, and here's how. We right-click on the chart, just to bring up the Chart Data section. Again, sometimes it's a little difficult to grab hold of, but if you click the different elements you should be able to find it.
Even though this is a pie chart so it doesn't have an obvious X and Y axis, we're still going with the basic principle that all reports in Reporting Services are concerned about numeric values and then category groupings, values being always numeric. Well if I look at the dataset we just have to think about what was the thing that had the number, what actually had the count, and it was the count of BusinessEntityID. That's what contained 1500 or 3200. So I am going to drag that across and drop it into the Values section.
The only other thing I need is the Category groups. What are we grouping these together by? Well, we are grouping by the CountryRegion, so I am going to drag that into Category groups. Again, it's still using a dummy data right now, so I am going to go ahead and run it, and that's looking pretty good. Okay, we haven't given it a chart title here, but I could go ahead and do that, and perhaps drag this a little lower to give us a bit more room. So this is great data for a pie chart. However, we've got a problem here. It's a little difficult to tell the comparative size of these slices.
That might not be hugely important, but it might be nice to figure out if, for example, the France section was bigger or smaller than the Canada section. So it'd be nice to have a bit more data. Well, that's easy to do as well. I am going to go back into Design view and then I'm going to right-click the chart, right-click in the middle of the pie chart here. One of the options is Show Data Labels. Click that, leave that as is, and just go back and run it again. Now, what we are getting here is the actual count, the actual values that have been returned by the query.
That's all well and good, but that might not be exactly what I was after. What I really wanted was percentages. Well, it's very easy to do as well. Back again into Design view. I need to select these labels again so I am just going to click in there until they are all highlighted, and they should select all at once. And then right-click. There should be an option called Series Label Properties. I'll select that one. The first option in general is, what's the label data? Where does this come from? By default, it's actually representing the actual number.
What I want it to represent instead is the percent, and there is an option in this dropdown box here. Now as soon as I select that it's going to just point out, okay, this property won't have any effect unless there is an option called UseValueAsLabel is set to False. It sounds cryptic; it really isn't. All it meant was under the hood there is actually an option saying, hey, I am actually using the value as the label. Is it okay to set that to false? Well, yes, it is, because I want to use percent as the label. So I'll click OK. The Font was a little small, so while I am here I am just going to drill into font and change that to 14 points. I might even change that to a white color, uncheck Bold. Click OK, and run it.
and now we have percentages. There it looks like I could do a bit of experimentation here. We're getting a bit of overlap, so I might make the font a little smaller, but you get the idea, and it's very easy to configure and very easy to change what we are seeing on this chart. Well while we're changing a few properties, let's change a couple more. Back into Design view, I've been using the basic generic style, which really is this basic set of colors here. We do have some options for what we want. If I click the View section and open up Properties, you'll find that by selecting the chart--again being careful I have the chart selected-- there should be an option here called Palette.
We've defaulted to the BrightPastel, but there is also the Chocolate Palette. There is also the EarthTones Palette. Some of these I don't think are all that useful because they just don't have enough distinction between them or they are a little too pale, but you can experiment with some that you might find a bit more useful. Not only that, but you'll find that every element of the chart has its own properties, its own set of customizable features. You just need to be very clear what you have selected, what you've clicked on. We have the title here, which right now is looking a little small so I could select that and use either the Properties panel or the actual Home section to give it a slightly bigger font.
I could select the Legend over here. Legend itself is quite interesting. If I right-click on this guy, it has its own set of Legend properties including things like changing the position of it. We have this little graphical representation about where we'd like to position the legend in relation to the rest of the chart. So just with a very little bit of experimenting, you can see how we can really drastically change the appearance of all our charts and that works not just for pie charts, but all the others as well.
There are currently no FAQs about SQL Server Reporting Services in Depth.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.