Report arguments - passing parameters to your event-based reports
This guide shows how to send additional information to your Event Rule reports directly from the event rules using report arguments.
How to use report arguments
When we generate the standard EV1000 report, we will get the usual information (Start Date, Start Time, Duration, Vehicle, etc). But, for example, we don't have the Speed information of the vehicle at the moment of the event by default.
To add a new variable (eg. Speed), follow these steps:
1. Open your event rule wizard under Admin > Event Rules
2. Create your event rule as preferred.
3. On step 5. Notifications select + to add a new notification type.
3. Select Report Argument as a notification type.
Using report arguments, we can easily include different report arguments such as speed and many others like:
4. Save your event rule.
After saving an event rule with the report arguments, you can run, for example, the EV1000 report. Remember to select in the report parameters to the right, the event rule that contains the report arguments:
Note: if you modify the Event Rule, and the report was previously run with the exact same parameters, you might need to reprocess the reports to see the changes applied.
In many cases, it is useful to use functions to get a more suitable result from a variable. For example, you can obtain the maximum or minimum speed of a vehicle during an event.
There are in total 5 functions that can be used in conjunction with variables:
- $START: The first value of the variable when the event starts
- $END: The last value of the variable when the event is still active but is about to end
- $FINAL: The final variable value when the event ended
- $MIN: The minimum value of the variable while the event is active
- $MAX: The maximum value of the variable while the event is active
By default, the value of the variable is the first value when the event starts. It behaves in the same way as the $START function.
Let's assume as an example, that you have an event rule monitoring a temperature signal over 10 degrees. The event rule has processed the following temperature values: [5, 11, 13, 12, 9]
The output for the different functions will be:
$FIRST([Temperature]) -> 11
$END([Temperature]) -> 12
$FINAL([Temperature]) -> 9
$MIN([Temperature]) -> 11
$MAX([Temperature]) -> 13
For developers: localized report arguments
Report arguments are localized. When creating custom reports including SUM/AVG/MIN/MAX functions, you may be using a culture (time/date display) setting generating decimal values with commas instead of dots, e.g. 45,3 instead of 45.3. That will generate an error in your reports since SUM/AVG/MIN/MAX can only handle decimal values with dots (and not commas). One solution is to modify "45,3" to "45.3".
You can do that using this syntax in your report query:
SELECT REPLACE(price,',','.') AS price, REPLACE(lastprice,',','.') AS lastprice FROM products
We aren't using invariant culture in these examples, since we most often want report arguments to be localized. However, you can read more about invariant culture here.
There are functions that can be included to obtain more information: $MAX, $MIN, $START, $FINAL and $END, for example: $MIN([SIGNAL_SPEED])
By default, the value that the variable gets is the one that triggers the event which would be the $START function. In order to use them, just add them to the Report Argument when selecting the variable according to the convention: $FUNCTION([VARIABLE]).
$FINAL() is empty on an ongoing event, and the end value when the event finishes. $END is the last value of an ongoing event, and the end value when the event finishes.