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

Grouping table regions on a report

From: SQL Server Reporting Services in Depth

Video: Grouping table regions on a report

So while it's very easy to create reports that just write out every row in a table, we often want to start grouping things a bit more meaningfully, and that's very easy to do in Reporting Services. And most of this grouping we'll actually do in the report itself rather than writing complex SQL to deal with it. So I am going to open up Report Builder again and create a blank report. The first thing I am going need here is the data source, so I will right-click and add a data source. I am going to connect again AdvertureWorkslight, so I will just give it a short name, AWLT, and this will be embedded in this report.

Grouping table regions on a report

So while it's very easy to create reports that just write out every row in a table, we often want to start grouping things a bit more meaningfully, and that's very easy to do in Reporting Services. And most of this grouping we'll actually do in the report itself rather than writing complex SQL to deal with it. So I am going to open up Report Builder again and create a blank report. The first thing I am going need here is the data source, so I will right-click and add a data source. I am going to connect again AdvertureWorkslight, so I will just give it a short name, AWLT, and this will be embedded in this report.

It is talking to SQL Server. I will click the Build button to start defining this. And the previous example I'd use the Server name dbserver. This is actually the address of my SQL Server 2008 R2 server, which means that using Windows authentication to connect to it, if I click the dropdown here, it will show me the databases that are in that SQL Server, which are the 2008 versions of my AdventureWorks database, along with a few others. But I could just as easily give it a different server address for a different version.

In fact, for me, my address of my SQL 2012 server is this one. So connecting again using my authentication here, if now I click the dropdown box, I will get the AdventureWorks 2012 versions that are installed on that SQL Server. Now, of course this is much more to deal with your organizational setup than it is with Reporting Services, but it's worth pointing out that it's very easy in this Connection window to connect to multiple different sources of data, as long as you're allowed to talk to that source of data. So I will select the AdventureWorksLT version and just test that connection. It looks good.

Click OK, click OK. We have our data source. Step two the dataset. So right- clicking here will add a dataset. This time I am going to go for a list of products. We are going to start grouping these in some meaningful fashion, so I will call this dataset products and it will be embedded in this report. It's going to ask what data source we are using. Well of course it's the one we just defined to AdventureWorksLT. And then I will come down and click the Query Designer button to actually specify the data that I want. So we are talking to that database.

It's showing us all the tables. I am going against the ProductTable. I could just select the checkbox to bring in every single column from that table, but it's good practice to only select the columns that you need. Now for me this time around it's going to be the product name, and I also want to know what category this product is in. Well, if I come down a little bit more in the product table, there is a ProductCatagoryID. This will be a numeric ID, which isn't all that useful, but it's what I am going to start with right now.

If I go ahead and click Run Query, we are going to see the name of our products coming back with this ProductCategoryID number as well, and the idea of course is there's multiple products in a particular category. We don't necessarily know what that category is, but we will get to that. I just want to do some grouping here. So I am going to ahead and click OK and say that that was my dataset. The next thing I need is something on this report that will actually write it out. So what are we trying to do here? Well, let's give it a title first.

I am going to click in here and say that this will be Products Grouped by Category. And because we know there will be multiple rows, we need some kind of repeating region here. I am going to jump up to my Insert tab, and the section we are interested in is the Data Regions. The one I want is the Table. I am clicking the dropdown arrow here; I am going to select Table Widget. The first thing that's going to ask for is what dataset is meant to fuel this table; it of course is the products dataset I just defined. Selecting that, I click Next. And this is where it's asking what fields to show.

And the previous version, what I've done is drag everything into the Value section. This time around what I am going to do is drag Name, as in the product name, into the Value section and Product Category ID into the Row groups section, telling this table I want to start grouping these rows together by the Product category ID. So if I have two rows with that product category of 18, they will be grouped together in that table. And we will see the impact that has visually in just a second. So this is a very simple example, but I like to start simple and build from this.

So I will go ahead and click Next. We now get an option for grouping. There are different visual options you can have where the things are shown beside each other. We have another option here for Blocked, with a subtotal above, Stepped in the subtotal above. It really doesn't matter in our example because we are so simple right now, so you can choose any one that looks visually appealing to you. I am just going to select these Stepped with subtotal above and click Next. Now we have the option of choosing a style. I am actually going to go ahead and click the Generic one, which is essentially style-free; it doesn't have background colors and no particular fonts here.

So with Generic selected, I will click Finish, and it drops in the table into our report. I am going grab the handle on this side and just drag it a little wider here so we have got more room to play with, and then from the Home tab of Report Builder, just click Run. And this is what our table is generating here. Our rows are actually grouped together into these categories, and they are collapsed by default. So we have the little plus box here that I can click and start opening up and seeing the products in that particular category.

Some of the categories only have one product in and some of them have two, some of them have many more. But as you can see, very easy to do, and we are going to see how we start to format this a little later on. However, our first problem is that this category number isn't very helpful, isn't very readable. We would really want to see a name written here rather than a number, but that information--the actual category name--is stored in a separate table. So next, we are going to see how to start to join tables together in Reporting Services.

Show transcript

This video is part of

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

40 video lessons · 9768 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.