OData - Part 2: Sorting


To sort data and gain more experience in the OData Wizard all while creating an employee directory.

Background Information

Assuming you’ve completed the previous tutorial and have a new employee directory in the works, you might be wondering “well, this is great and all, but aren’t directories supposed to be sorted by last name or something?” And you are exactly right!! Now we need to figure out how to sort using the OData Wizard.


Inserting a Tag, ForEach Tag, OData - Part 1: Basic Selection

Starting Template

This tutorial is a continuation of the OData - Part 1: Basic Selection tutorial. We will start off with the template as it is at the end of that tutorial, so if you haven’t already, you should check that tutorial out (it won’t take very long)!


1. Open the OData Wizard for the ForEach tag

As with the previous tutorial, we need to open the SQL Wizard again. Do this by selecting the ForEach tag [forEach Employee: and clicking the Wizard button in the AutoTag ribbon.

Show Me How!

2. Drag LastName to Sort

First and foremost, we would like to sort the directory by last name. In order to do this, you drag the LastName property under Employees over to the OrderBy box. You can see the results change in the right panel.

Show Me How!

3. Drag FirstName to Sort

If there are two people with the same last name, it makes sense also to sort them then by first name. To do this, drag the FirstName property to the OrderBy box and place it under LastName.

Show Me How!

4. Generate and view results

Finally, generate a document and see what you have created. This step should be very familiar to you by now, but if not, please check out the Inserting a Tag tutorial.

Show Me How!

Quiz Yourself!

Can you sort OData data listed in a table using ForEach tags in AutoTag?
Yes. All I have to do is drag the properties I want to sort by into the Sort box in the OData Wizard
Yes, but I have to program it myself which sounds like a daunting task, so no.
Yea, just hit the magic “sort” button in the Home ribbon of Microsoft Word after generating my document. Every time I generate it.
No. The only way I can have sorted data in my generated documents is if the data is already sorted.
True/False: You can only sort by one property. In cases where several rows have the same data in that column, those rows appear together in a random order.
False. I can sort by as many properties in as many ways as I want.
False. After generating the report, I can sort it the rest of the way using Microsoft Word’s magic “Sort” button.
Kind of true. I can sort by two properties, but no more than that.
True. This is an unfortunate limitation that I wish could be amended.


You have completed this tutorial. We recommend taking a look at the OData - Part 3: Filtering with Static Values tutorial next!