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

Sorting data in a data region

From: SQL Server Reporting Services in Depth

Video: Sorting data in a data region

We've seen how to filter our datasets and even apply parameters to them. What we haven't talked about yet is how to sort our data, so let's see that now. I am in Report Builder, where I've just created a new blank report, and all I have done is define a simple data source pointing to the regular AdventureWorks database. I'll give this report a simple title, and I'm now going to create the dataset. This will be embedded in my report, and what I'm going to make it do is point to the person table that's in the AdventureWorks database, just bringing back a list of people. It really doesn't matter what data we have.

Sorting data in a data region

We've seen how to filter our datasets and even apply parameters to them. What we haven't talked about yet is how to sort our data, so let's see that now. I am in Report Builder, where I've just created a new blank report, and all I have done is define a simple data source pointing to the regular AdventureWorks database. I'll give this report a simple title, and I'm now going to create the dataset. This will be embedded in my report, and what I'm going to make it do is point to the person table that's in the AdventureWorks database, just bringing back a list of people. It really doesn't matter what data we have.

I just need something to illustrate these sorting concepts. So I'm going to jump into the Query Designer, drill down into that Person table and select a few pieces of data. We'll go for FirstName, LastName, and I'll also select rowguid, which is the generated unique identity for this row, just so we have some other piece of data to take a look at. Now, we've seen that in the Query Designer window there are ways we can apply filters to the data and even parameterize it. There are ways we can auto detect relationships, and even up here which shows the fields I have selected if I wanted to apply an aggregate function, I could actually do that right here. But there doesn't seem to be a way to sort that data.

So I can run this query to test it, and I'm really at the mercy off how the database is internally structured. Here I don't have this information coming back in any kind of a meaningful sort order. That's more to do with the indexes that are defined on this table than anything else. So what if I wanted to have this sorted by first name ascending or last name descending? Well, if you're familiar with SQL, you know that's pretty simple to do, so you might be tempted to add it yourself. One of the ways I could do is just click the Edit as Text button up here and I could be tempted to just add in an SQL ORDER By statement and say order by last name descending or first name ascending.

Now this would work, but it's not the way we would normally do things in Reporting Services. This is another instance where we should bring back the data that we want. Just don't worry about sorting it in the query in the dataset. Instead, we'll sort it in the report, in our data region, our table or matrix. So I'll click OK. That's my dataset defined. Now I'll jump into the Insert tab and just insert a simple table here. Choose that dataset. I'm going to drag on FirstName and LastName.

I could drag on rowguid. It really doesn't matter if I do or not. I'm not bothering with grouping them together in any category. I'm just having a list of people. And I'll except all the other defaults and just add that to the report. Go ahead and run this and we've got our data, but right now I'm at the mercy of how this database is internally structured. I might get lucky, but I want some other behavior. So I'm going to decide to sort these by last name ascending, go back into Design view, and what I want to do is select the table, so clicking somewhere inside the table to get the gray bars along the top. I'll then select the top corner to make sure that I have Tablix selected in my Properties window, and then open the Properties Pages. And over here we have the Sorting option.

So it's saying I don't care about how this actually comes back from the database; I'm going to sort it in our table here. If I click the Add button, I then get the option to Sort by, and I'll say LastName, A to Z, so ascending. That's fine. Click OK. That's it. We now have a LastName ascending applied to the table. If I wanted to be explicit about multiple levels of sorting, I'd go back into the table, into the Property Pages, and add multiple levels of sorting here, making sure I sort by last name and then by first name and then by middle name and so on.

But it's just as easy to change the order of that, to make it descending. I'll try that again. No surprise here. Now we're descending last name order. And this might work for a lot of what you present, but what's also very useful is to be able to apply interactive sorting, to let the end user sort the data whatever way they want to. So let's see how to do that.

Show transcript

This video is part of

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

40 video lessons · 10659 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 preferences from 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.