Variables

Variables can be used with the Expression Builder to set filter using the Advanced QBE Filtering window or aggregate fields. All variables must start with a $ and cannot contain spaces (for example $var is a variable called 'var'). In this section we will use a variable to set Advanced QBE Filtering in a view which will only display records that have an end date that is less than a week old.

  1. Open the View Editor by clicking on the wrench icon in the middle of the screen and selecting Add View under Views.
  2. Enter a name for the view.
  3. Click on the button next to Filter to bring up the Filter and Sort window.
  4. Click on Advanced QBE Filtering to bring up the Advanced QBE Filtering window, this is where we will enter our filtering condition.
  5. Type in a variable name in a field in the advanced QBE filtering window, lets name the variable $Date.
  6. Now in the Condition portion of the Advanced Search dialog we can use this variable in our expression. Type in $Date in the Condition area.
  7. Under Operators select General Compare Operators and then click on Greater Than.
  8. Click on Functions and under Context Functions select the current-date function. A bubble will appear describing what the current-date function does and how to use it.
  9. Under Operators select Arithmetic Operators and then click on Minus.
  10. To add a one week duration to the expression click on the calendar icon and select Duration.

    This will bring up the Input dayTime Duration window. Click on dateTime for the duration type and enter 7 in the Days section.
  11. The final filtering condition is shown below, notice that when you select 7 days for the duration the expression to format the duration is automatically added.
  12. Click on Done to close the Advanced Search Dialog and then Done again to close the Filter and Sort window.
  13. Define the columns in your view by using the View Editor.
  14. When finished click Save and Exit to exit the View Editor and save the changes.

Remember that variables will take the format of the fields they represent. For example if you create a variable that represents the "Creation Date" standard property the variable will be in a Date-Time format. If you wish to compare the "Creation Date" standard property to the current date you will need to use the current-dateTime() function and not the current-date() function. The correct format would look something like this: xs:dateTime($variable)<current-dateTime().