Use Set Functions

Top Previous Topic Next Topic  Print this topic

In this example, the use of dataset functions will be illustrated through a simple example: Sort.

 

The document created in our previous tutorial, Using Functions, will be used for exemplifying the dataset function.

 

example2-2

 

Step 1: Inserting the desired dataset function

 

For this scenario, a sorted version of the Emp table must be used. In order to sort the data, the Sort dataset function must be inserted by selecting the Sort button located in the Dataset group, under the Home tab.

An ascending sorting order will be used for the "FIRST_NAME" field.

 

Step 2: Binding the data

 

First, the data source connection between the Emp table and the XML Output must be deleted. This can be easily achieved by selecting the line that binds the connectors and pressing the Delete button.

 

Then, the data must be connected, as follows:

 

example3-1

 

The data source has been passed through the Sort dataset function before being aggregated in the XML Output.

 

Step 3: Viewing the output

 

To view the output, the user must access the View tab and select Output View, or press CTRL + Page Down while in Design View. The following XML will be displayed:

 

 

       <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

       <ns:root xmlns:ns="http://www.tempuri.org/XML">

               <ns:dbo.emp id="3" first-name="Arthur" last-name="Clark" full-name="Arthur, Clark"/>

               <ns:dbo.emp id="1" first-name="John" last-name="Brown" full-name="John, Brown"/>

               <ns:dbo.emp id="2" first-name="Mary" last-name="Jane" full-name="Mary, Jane"/>

       </ns:root>

 

 

Note:

The above example is part of the SortSample.dax document, located in the Samples/Job Samples folder.