Lab 12 – Use ActiveFactory Query 6-21
Query 7 – Reporting
The procedure presented here is useful for preparation of reports.
The queries prepared in this section will be saved and re-used in SQL Server Management Studio.
Consider the case where we want to create a report for the Mixer.
To get report information, we want to create the following query:
z When did the mixer level exceed the Hi Alarm Limit for the LIT_001.PV tag during the Last
Hour?
For this example, you will assume the Hi Alarm Limit is 90.
64. Create a History Values query for the LIT_001.PV tag.
65. Using the tab fields for the History Values query type, assign the following attributes:
Tab or Pane Tab Field/Area Set the following Options to:
Query Type History Values
Tag Picker Pane Tag Type Analog
TagName LIT_001.PV
Columns z Tagname
z Date and Time (default)
z Include milliseconds
Time 1 Hour
Format Narrow
Criteria z Value > 90
Retrieval z Delta: rows are returned only when data
changes.
z Limit to first 0 rows
Note: Setting the number of rows to '0' will result in
all stored values being used.
66. Select the Data tab (Execute the query).
Wonderware System Platform Course - Part 2
6-22 Module 6 – ActiveFactory Query
67. Click the SQL tab.
68. Save the current Query in your Favorites Folder as [Link].
69. Open Windows Explorer.
70. Browse to: C:\Documents and Settings\[user]\Local Settings\Application
Data\Wonderware\ActiveFactory\Queries.
71. Double-click the [Link] file to open it with SQL Server Management Studio.
72. Connect to the Server using a Login and Password of wwUser.
73. Change the database to Runtime.
74. Execute the query.
75. Compare the results in Microsoft SQL Server Management Studio to the results obtained in
ActiveFactory Query. They should be identical.
This enables you to build queries using ActiveFactory Query, and re-use them in any other SQL
Client.
Wonderware Training
Lab 13 – Use ActiveFactory Query in Excel 6-23
Lab 13 – Use ActiveFactory Query in Excel
Introduction
In the previous Module, you learned how to use ActiveFactory Workbook to return Historian tag
values. ActiveFactory Workbook also contains a query building tool called Direct Query which
allows you to embed entire queries in a Microsoft Excel Workbook.
Objective
Upon completion of this lab you will be able to:
z Create SQL Queries and View the Results in Workbook
Wonderware System Platform Course - Part 2
6-24 Module 6 – ActiveFactory Query
ActiveFactory Query in Excel
1. Start Microsoft Excel.
2. Select cell A1.
3. Select ActiveFactory / Direct Query from the ActiveFactory pull-down menu.
The Direct Query editor appears:
4. Click the Query Builder button. .
The Query Builder button launches a version of ActiveFactory’s Query application.
Using Query, we can build a History Values query for display in Excel format.
5. Select History Values from the Query Type: drop-down list.
6. Select the Analog tab in the Tags pane of the Query builder.
7. Holding the Control key, select the following tags:
z LIT_001.PV
z TT_001.PV
z TransferPump_001.SpeedAvg
z TransferPump_001.TempAvg
8. Select 5 Minutes from the Time Tab.
9. Select Wide query format in the Format tab.
Wonderware Training
Lab 13 – Use ActiveFactory Query in Excel 6-25
This format ensures the tagname will be the column title, which is easier to read for some
types of queries.
Leave all other settings. The Default mode for this query is Cyclic, with a row count of 100.
Wonderware System Platform Course - Part 2
6-26 Module 6 – ActiveFactory Query
10. Select the Data tab to ensure that a valid result appears in the lower pane:
11. Click OK.
The Direct Query dialog re-appears. It now contains the query we just built:
12. Click OK.
Wonderware Training
Lab 13 – Use ActiveFactory Query in Excel 6-27
The results appear on the spreadsheet in the selected format.
Note the red triangle in cell A1.
13. Click the cell field with the red triangle to display the query that was just built (The query is
inserted into cell A1, and a wwQuery function has been inserted into cell A3, which references
cell A1).
14. Right-click the tab (Sheet1 in the previous figure), and select Rename.
15. Rename the sheet Direct Query and press the Enter key.
16. Click Save.
17. Name the file [Link] and save it in the C:\Wonderware Training\Labs folder.
Wonderware System Platform Course - Part 2
6-28 Module 6 – ActiveFactory Query
– Intentionally left blank –
Wonderware Training
Module 7
ActiveFactory Report
Section 1 – Introduction 7-3
Lab 14 – Using ActiveFactory Report 7-7
Lab 15 – Wildcard Time Options and Report Editing 7-15
7-2 Module 7 – ActiveFactory Report
Module Objectives
z Show and explain Report GUI elements/functionality.
z Successfully use the Report application to create a Historian data report using the MS
Word document format.
Wonderware Training