Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Creating a pie chart

From: SQL Server Reporting Services in Depth

Video: Creating a pie chart

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.

Creating a pie chart

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.

Show transcript

This video is part of

Image for SQL Server Reporting Services in Depth
SQL Server Reporting Services in Depth

40 video lessons · 9764 viewers

Simon Allardice
Author

 
Expand all | Collapse all
  1. 12m 6s
    1. Welcome
      1m 9s
    2. What you need to know
      1m 36s
    3. Exploring SQL Server Reporting Services components
      4m 17s
    4. Reviewing SQL Server versions
      5m 4s
  2. 49m 41s
    1. The elements of a report
      3m 10s
    2. Creating a report with Report Builder
      12m 11s
    3. Grouping table regions on a report
      6m 1s
    4. Joining data from multiple tables
      4m 33s
    5. Formatting report elements
      4m 34s
    6. Using functions in a report
      11m 0s
    7. Displaying data in a matrix
      8m 12s
  3. 24m 9s
    1. Filtering data and adding parameters to a report
      5m 35s
    2. Customizing report parameters
      5m 4s
    3. Sorting data in a data region
      4m 7s
    4. Applying interactive sorting
      4m 57s
    5. Creating a drillthrough action to connect reports
      4m 26s
  4. 49m 57s
    1. Introduction to charting in Reporting Services
      4m 16s
    2. Creating a column chart
      8m 35s
    3. Adding a generated average to a chart
      4m 5s
    4. Creating a pie chart
      8m 19s
    5. Using sparklines
      6m 38s
    6. Adding a sparkline to a drilldown matrix
      14m 34s
    7. Adding data bars
      3m 30s
  5. 21m 48s
    1. Adding indicators to a report
      7m 52s
    2. Using and configuring gauges
      5m 30s
    3. Using maps in Reporting Services
      8m 26s
  6. 38m 14s
    1. Creating modular reports with report parts
      4m 36s
    2. Adding and updating report parts
      4m 37s
    3. Using subreports and nested regions
      4m 28s
    4. Configuring headers and footers
      3m 9s
    5. Printing and exporting reports
      3m 45s
    6. Using page breaks
      5m 37s
    7. Creating and using shared data sources
      8m 11s
    8. Creating and using shared data sets
      3m 51s
  7. 27m 20s
    1. Organizing reports in Report Manager
      3m 1s
    2. Adding users and configuring report security
      5m 24s
    3. Configuring subscriptions
      5m 13s
    4. Creating a linked report
      4m 8s
    5. Using Report Designer in SQL Server Data Tools
      9m 34s
  8. 1m 2s
    1. Goodbye
      1m 2s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed SQL Server Reporting Services in Depth.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.