In this tip, we continue from where we left off with the previous tip, and will demonstrate how you can use system variables when scheduling reports to run automatically. This will reinforce how they are applied during the scheduling process. If you didn’t catch the previous tip, you can find it here.
There are many scenarios where using system variables with scheduled reports becomes beneficial. Two of them are as follows:
- You can schedule a report to run in the future, and have the data pulled from the day the report is run (even if you are not at your computer to choose the variables). For example, I want my report to run three weeks from now showing all the latest data, including any new information entered up until then.
- You can schedule a report to run on a regular basis, showing data for a particular timeframe, based on the run date. For example, I want my report to run on the last day of every month, showing data for that month.
The last example is similar to what we started with in the previous tip, and we’re now going to continue with it, showing how to include the system variables for the purpose of scheduling your report.
1.To schedule a report, you first need to generate a scheduler command, which you do by right clicking on it in the Report Manager and selecting the Scheduler Command option.
2. Once you do that, a dialogue will appear asking you for the dates you would like to use for the parameters in your report each time it is run, according to your schedule. Although system variables were added as the comparators to start with, you’ll notice the actual dates are substituted for them in the dialogue.
3. To ensure the use of variables, you need to enter them again here. You can do so by typing them directly into the fields as shown.
4. After clicking OK, you can continue with the creation of your schedule using the Windows Task Scheduler. In case you haven’t gone through the last tip, you can find a video on how to do this here. It also provides another example of using system variables.
You will notice in the above scenario that although I used @MONTHSTART@ and @DATE@ initially for the parameters, I used @MONTHSTART@ and @MONTHEND@ for my scheduler command. You may find many useful combinations of parameters and system variables to use for the purpose of scheduling your reports, as long as they apply to the type of field used that the parameter is based on. For example, you can’t have a date system variable applied to a parameter based on a period field, or a month system variable applied to a year field. If you would like to browse the available system variables from within the Report Manager, you can do so using the option found under the tools tab.