Tutorial 3
Creating a simple calculated field
This tutorial assumes you have the knowledge gained from working with the previous tutorials. After this tutorial you will have the knowledge to add calculated fields together with their calculations (expressions) to any query that you write. Calculated fields can contain very complex expressions, nested to multiple levels, but this tutorial will just demonstrate the creation of the most basic calculation to give you an idea of what can be achieved using this function.
Perform the following steps:
- If the Query Designer Tool is already running, please close it down. Invoke the NuVu Query Designer from the NuVu Query program group from the windows Start menu. The main NuVu Query Designer window will be displayed, and a welcome dialog window will also be displayed that shows recently saved/opened queries. We are going to create a new query from the previous query (tutorial2), so double-click on the ‘tutorial2′ item that should be displayed inside the Welcome dialog window (if you have successfully performed the previous tutorial and saved it as specified in that tutorial with a name of‘tutorial2′). The original query will open inside the Designer. We need to now save this as ‘tutorial3′ before we start working with the query, so click on theFile->Save As menu item and advise a new Query name of tutorial3 when the save properties are displayed.Click the button to save the query with the new advised name.
- Click the (calculated fields) button on the toolbar to invoke the calculated fields dialog window.
- Click the (add item) button on the update panel near the top of the screen. This will create a new empty row into the calculated fields grid and position you on the fieldname column.
- Advise the details as shown below:Once the details have been advised, click on the expression editor which is located at the bottom of this screen so that the cursor is positioned within that editor.
- Our calculation is going to simply subtract the contents of the ‘Balance’ field from the ‘CreditLimit’ field and show this difference. Advise the details as shown below, but a hint here – double-click the fields in the field browser window to automatically copy them down to the editor, ensuring that there is a minus sign (with a space on either side of it) between the two fields:
- Click the (Post changes) button located at the top of the screen to save your new calculated field.
- Click the button to save all changes to the calculated fields. The calculated fields dialog window will close.
- Click the button to start execution of the query. A dialog window will appear briefly indicating the various steps that are being performed. Once the query results have been retrieved, this dialog window will disappear and the results will be shown inside the grid on the designer window, as shown below:
- Note the new ‘Difference’ column that displays the difference between the CreditLimit and Balance fields.
- Finally we will save the changes made to this query (as this will form the base query for the next tutorial), so simply click the button and close down the query tool.
We are complete with the tutorial. An exported query containing this tutorial is available by right-clicking here and choosing Save Link As (Firefox) or Save Target As (Internet Explorer) to save the query import format file to a file on your hard disk, and then importing that query into the query tool (hint: choose File->Import Query from the main menu of the Query Designer).
End of Tutorial