Median
Table of Contents
Note:
- This task is applicable only to Zoho Creator.
Overview
The median function in the "aggregate records" deluge task fetches records based on a specified criteria and sorts them in ascending order based on a specified field, and then returns the specified field's value from the median(lying in the middle) record if the number of records is even, or returns the average of the specified field's values from the median two records if the number of the records is odd.
The criteria is mandatory.
This function can be applied to the following field types:
- Number
- Percent
- Currency
- Decimal
- Formula (numeric)
Return
Based on the specified field, the data-type of the returned value could be one of the following:
- If the specified field type is Number, or Formula(bigint) the data type of the return value will be Number.
- If the specified field type is Percent, Currency, Decimal, or Formula(decimal), the data type of the return value will be Decimal.
Syntax
<variable> = <form_link_name> [<criteria>].median(<field_link_name>);
Param | Explanation | |
---|---|---|
<form_link_name> | Link name of the form from which the records will be fetched. | |
<criteria> | Criteria based on which records will be fetched. | |
median(<field_link_name>) | Link name of the field to which the median function will be applied. The "median" aggregate function can be applied to the following field types:
|
Things to keep in mind
- If you wish to fetch all records of the specified form, use the following script as criteria:[ID != 0]
It is advisable to fetch all records only when absolutely needed. Fetching all records generates a load resulting in performance issues.
This task can be used in the following events
When a record is Created | ||
On Load | Yes | |
On Validate | Yes | |
On Success | Yes | |
On User input | Yes | |
Subform on add row | Yes | |
Subform on delete row | Yes | |
When a record is Created or Edited | ||
On Load | Yes | |
On Validate | Yes | |
On Success | Yes | |
On User input | Yes | |
Subform on add row | Yes | |
Subform on delete row | Yes | |
When a record is Edited | ||
On Load | Yes | |
On Validate | Yes | |
On Success | Yes | |
On User input | Yes | |
Subform on add row | Yes | |
Subform on delete row | Yes | |
When a record is Deleted | ||
On Validate | Yes | |
On Success | Yes | |
Other workflow events | ||
On a scheduled date | Yes | |
During approval process | Yes | |
During payment process | Yes | |
In a Custom Function | Yes | |
In an Action item in report | Yes |
Example
The following script returns the value of "age" field in the median record from the Employees form.