Report Designer: Data Objects

A data object is a container for reportable information from a source of data. For example, a payroll report may include an Employees data object with census data such as names, addresses and hire dates as well as a Time data object with clock-in and clock-out times for each employee's shift start and end.

When creating a new Advanced Report, data objects will be added to the report with the Add Data Objects dialog, which will appears when launched for the first time.

nEG788AXzs.png

.

Data Objects Dialog

The Data Objects Dialog consists of two main parts:

Available Data Objects Tree 

The data objects tree on the left side of the dialog shows all of the available data objects that can be added to a report. A Search... field at the top of the tree allows searching for data objects by name.

huUUJd3fPq.png

There are two data objects in the Northwind folder of this data objects tree: Categories and Products

If the system administrator has enabled it, custom SQL statements may be added as a data object in lieu of selecting one of the existing objects. For more information, refer to the Custom SQL Objects section of this article.

Selecting a Data Object from the list and clicking on the View Data Object Details i in a circle icon will display the names of the fields that are available in that object.

w7pc9HG2YU.png

CompanyName, Phone and ShipperID are fields available in the Shippers data object

Selected Data Objects Panel 

The selected data objects panel on the right side of the dialog is where the added data objects appear and is divided into three or four columns depending on system configuration.

1UtFUfsTod.png

Three data objects have been added to this report: Categories, Products and Orders

Add, Edit or Delete Data Objects to/from a Report

The Add Data Objects dialog can be recalled at any time by clicking the stacks Manage Data Objects button in the Data Objects Pane

Custom SQL Objects

This is an advanced feature, and the system administrator must enable it for it to be available.

 Important
If a Custom SQL Object is added as a data object to a report, it may be the only data object on that report.

Custom SQL Objects may only be added to new report, not an existing report.

5HG87d9rVS.png

Custom SQL Object dialog

Writing Custom SQL Objects requires underlying knowledge of the data source architecture and its relevant SQL language.

To add a Custom SQL Object to a report:

  1. Click the + Add SQL button in the Add Data Objects dialog to open the Custom SQL Object dialog.
  2. Provide a unique Object Name for the new data object. It cannot match any existing data object in the system configuration nor contain any of the following characters, including spaces: [ ] { } . , @
  3. Choose the Data Source that this Custom SQL Object will retrieve data from. Not all data sources in the system may support Custom SQL objects.
  4. In the large code window (shown with a line number 1 in the figure above), enter the full SQL statement. This statement will be inserted as a sub query when it is sent to the data source for processing.

     Caution
    ORDER BY clauses are not supported in sub queries. To sort a report with a Custom SQL Data Object, use the Sorts dialog built-in to the Report Designer.

  5. System variables called parameters, that change based on certain environmental situations (e.g. who is running the report) may optionally be added to the SQL statement by selecting the name from the dropdown and clicking the + Insert Parameter button.
    To add a new report-level parameter to the report, and the system administrator has enabled it, first click the New Parameter button to open the Report Parameters dialog.
  6. Click the Test green checkmark icon to check the SQL statement for validity.
  7. Click the Unique Key Fields list to select unique keys for the custom SQL object. Select the columns that uniquely identity a record in this object.
    QXpD7SSqsy.png
    1. Click the + Add button to add a unique key field to the list.
    2. Select the name of the field from the dropdown, or click the Delete X icon to remove it.
    3. Once all unique key fields are defined, click Okay.
  8. Click Okay to close the Custom SQL Object dialog and save the object to the Add Data Objects dialog.

To edit a Custom SQL Object:

  1. On the Report Settings menu from the toolbar, click the stacks Manage Data Objects button in the Data Objects Pane to open the Add Data Object dialog.
  2. Click the Custom SQL Object SQL icon in the Data Object Name column to open the Custom SQL Object dialog.
  3. Follow the instructions in the add a Custom SQL Object section above to edit the object.

Example

The following Custom SQL Object could be used to generate the basic report shown below with order IDs and dates of each order placed by each salesperson in the company in a certain month.

SELECT  dbo.[Orders].[OrderID] AS c0, dbo.[Orders].[OrderDate] AS c1, dbo.[Employees].[FirstName] AS c2, dbo.[Employees].[LastName] AS c3, dbo.[Employees].[EmployeeID] AS c4, dbo.[Orders].[EmployeeID] AS c5FROM dbo.[Employees]INNER JOIN dbo.[Orders] ON ( dbo.[Employees].[EmployeeID] = dbo.[Orders].[EmployeeID])WHERE  Month(dbo.[Orders].[OrderDate]) = 7

656bAbKYcz.png

Handling Duplicate Values

Causes of Duplicate Values

Be judicious when adding data objects. If the report has unexpected duplicate values or empty rows, the cause is most likely there is a one-to-many join to an object not being used.

Resolving Duplicate Values

Consider a report that lists the students that are advised by professors at a college. This requires the Professors and Students data objects, which have a one-to-many relationship as one professor may advise several students. Adding fields from both of these data objects to a report will result in duplicate data.

true

Sample report design

true

Sample report output

There are a few ways to handle situations like this.

  1. Utilize Group Sections
  2. Apply Hide Repeated Values to the Data Objects
  3. Apply Hide Repeated Values to the cell
  4. Address the Data Model

1. Utilize Group Sections

Group Header sections and Group Footer sections can be used to display data from the "one" side of a "one-to-many" relationship. For reports that show several one-to-many relationships, consider using Repeating Groups.

This feature checks unique keys in the data objects so that a professor only appears once on the report. Since each professor is identified with a unique key in the data source, even if there is a professor with the same name, they will appear since they are not the same professor.

true

The sample report layout has been updated to include a Group Header section on the professor's last name

The effect of this change is that all advisees are now listed under the heading of each professor's name

2. Apply Hide Repeated Values to the Data Objects 

The Hide Repeated Values checkbox in the Manage Data Objects dialog will hide any data from a duplicated record from appearing on the report. This is a visibility change only—there is no change to aggregation, SQL generation or the number of rows returned from the data source.

This feature does not check unique keys in the data objects, it looks at only the values displayed in the cells. Caution should be exercised when using this method if there could be unique duplicate data. For example, if there is another professor named Joyce Anderson, that professor's name would not appear on the report output.

Hide Repeated Values is enabled for the Professors data object in the sample report

 

For illustrative purposes, the professor's first and last names now appear in their own cells in the report design

Any time a duplicate value comes up for a Professors record, all of the fields for that record are removed from the report. Therefore, both the first and last names do not appear more than once for each professor

3. Apply Hide Repeated Values to a Cell 

The Hide Repeated Values icon on the toolbar will suppress only the value in the cell it is applied to if the previous value is the same. This is a visibility change only—there is no change to aggregation, SQL generation or the number of rows returned from the data source.

This feature does not check unique keys in the data objects, it looks at only the value displayed in the cell. Caution should be exercised when using this method if there could be unique duplicate data. For example, if there is another professor with last name Anderson, that professor's name would not appear on the report list.

This report has the Hide Repeated Values feature enabled only on the professor's last name cell, so when the previous row has the same last name, it is hidden from the report

Since the cells where the duplicates have been removed are empty, this can be tested for with a conditional formatting formula for other report manipulation.

4. Address the Data Model 

If still seeing duplicates after trying the above options, it is likely a result of a Cartesian product. Consider: