The Array functions work with multi-valued data or lists in arrays and, in this way, are not dissimilar to the Group functions.
They are used primarily with the multi-valued Array.Tags field and the various All Roles fields that apply to subject, class and cohort records. For example, you could extract the name of the first teacher from the list of teachers assigned to a class.
The Array() function converts a set of single values into an array, whereas most of the other functions extract single values from an array.
The Index() and Ordinal() functions, and the various permutations of these, refer to an array or list of values, and are very useful in many calculations, eg converting grades to numbers, averaging, and then converting them back again.
Arguments
|
expr is any set of expressions
|
Returns
|
A multi-valued expression
|
Action/Description
|
Converts the set of single values into a multi-valued expression so it may be used by the Group functions.
|
Example syntax
|
DConcat(Array({WR1}, {WR2}, {WR3}, {WR4}), " – ")
|
Example usage/s
|
The group functions accept multi-valued parameters. The array function can be used to create a multi-valued parameter.
The Array function can also be written as a list of values in square brackets, eg:
DConcat([{WR1}, {WR2}, {WR3}, {WR4}], " – ")
|
Arguments
|
list is multi-valued argument containing a set of values
|
Returns
|
A string
|
Action/Description
|
Extracts the first value in the set of values
|
Example syntax
|
First({Cl.Roles.TPF})
First({AI.Tags}) = Last({AI.Tags})
|
Example usage/s
|
The function is used where only the first of a set of values is required, eg the first teacher where there are multiple teachers of a class. It may also be used where there is only one value, eg one teacher role only exists in the database, to convert the field from an array to a string.
In the first example above, if teachers John Smith and Mary Brown taught a class, Mr John Smith would be returned.
The First function can be used in conjunction with Last() to determine if there is only one value in an array, as shown in the second example above, which could be inserted into a Filter operator to ensure that only assessment items with one specific tag are extracted.
However, with some multi-valued fields, where blanks are allowed, it would be better to use FirstX() and LastX().
|
Arguments
|
list is multi-valued argument containing a set of values
|
Returns
|
A string
|
Action/Description
|
Extracts the first non-blank value in the set of values
|
Example syntax
|
FirstX({Sb.Roles.Code})
If(FirstX({Cl.Roles.TPF}) = LastX({Cl.Roles.TPF}), "teacher", "teachers")
|
Example usage/s
|
The function is used where only the first of a set of values is required, eg the first teacher where there are multiple teachers of a class but you cannot be sure if the first role contains a blank or not.
In the first example above, if the school had three subject level roles and the array Sb.Roles.Code was [ ,SMIJ,BROM], SMIJ would be returned.
FirstX() in conjunction with LastX() can be used to determine if there is only one non-blank value in an array. In the second example above, if there is only one teacher, the singular teacher is inserted, otherwise the plural is inserted.
|
Arguments
|
num is a number representing which item in the list to return
list is a multi-valued argument containing the possible set of values that can be returned
|
Returns
|
Numeric or text string
|
Action/Description
|
Returns the item in a given array at the location specified.
|
Example syntax
|
Index({TASK1}, ["Good", "Better", "Best"])
Index(DAvg(Ordinal([{AT1}, {AT2}, {AT3}], {AT1.List})), {AT1.List})
Index(DAvg(Ordinal([{AT1}, {AT2}, {AT3}], ['E','D','C','B','A'])), ['E','D','C','B','A'])
|
Example usage/s
|
The first example allows TASK1 to contain a result between 1 and 3. If the result is 1, the function returns Good; a result of 2 returns Better and 3 returns Best.
The second example shows the way to average a set of letter grades, eg A, B, C … into a letter grade. The Ordinal function converts each of the three letter grades into a numeric ordinal, which is then averaged by the DAvg function, and finally converted back into a letter grade by the Index function. However, in this case, it would be assumed that the list of values for the assessment item AT1 were in the appropriate order, ie from lowest to highest, ie E, D, C, B, A. Otherwise, when the values are averaged, they will be rounded down rather than up. Therefore, you could replace {AT1.List} with an array of the actual values in the correct order, as shown in the third example above.
The RevIndex function may be used as an alternative to Index, where you want the index to begin from the end of the list, rather than the beginning.
|
Arguments
|
num is a number representing which item in the list to return
list is a multi-valued argument containing the possible set of values that can be returned
|
Returns
|
Numeric or text string
|
Action/Description
|
Returns the item in a given array at the location specified. However, any missing items in the list are skipped.
|
Example syntax
|
IndexX(2,[{WR1}, {WR2}, {WR3}, {WR4}, {WR5}])
IndexX(1,{Cl.Roles.Code})
|
Example usage/s
|
In the first example, where results are stored in the WR1 to WR5 items, the second non-blank result will be returned. For example, if WR1 and WR2 are not missing, WR2 will be returned. If WR2 is missing, WR3 will be returned, if not blank, and so forth.
The second example will return the first non-blank class teacher role and is, therefore, the equivalent of FirstX({Cl.Roles.Code}).
|
Arguments
|
list is multi-valued argument containing a set of values
|
Returns
|
A string
|
Action/Description
|
Extracts the last value in the set of values
|
Example syntax
|
First({Cl.Roles.TPF})
First({AI.Tags}) = Last({AI.Tags})
|
Example usage/s
|
The function is used where only the last of a set of values is required, eg the last teacher where there are multiple teachers of a class. It may also be used where there is only one value, eg one teacher role only exists in the database, to convert the field from an array to a string.
In the first example above, if teachers John Smith and Mary Brown taught a class, Ms Mary Brown would be returned.
The First function can be used in conjunction with Last() to determine if there is only one value in an array, as shown in the second example, which could be inserted into a Filter operator to ensure that only assessment items with one specific tag are extracted.
However, with some multi-valued fields, where blanks are allowed, it would be better to use FirstX() and LastX().
|
Arguments
|
list is multi-valued argument containing a set of values
|
Returns
|
A string
|
Action/Description
|
Extracts the last non-blank value in the set of values
|
Example syntax
|
FirstX({Sb.Roles.Code})
If(FirstX({Cl.Roles.TPF}) = LastX({Cl.Roles.TPF}), "teacher", "teachers")
|
Example usage/s
|
The function is used where only the last of a set of values is required, eg the first teacher where there are multiple teachers of a class but you cannot be sure if the last role contains a blank or not.
In the first example above, if the school had three subject level roles and the array Sb.Roles.Code was [SMIJ,BROM, ], BROM would be returned.
FirstX() in conjunction with LastX() can be used to determine if there is only one non-blank value in an array. In the second example, if there is only one teacher, the singular teacher is inserted, otherwise the plural is inserted.
|
Arguments
|
expr is any expression
list is an array of values against which the expression will be matched, typically being sorted from best to worst.
|
Returns
|
Number
|
Action/Description
|
Returns the ordinal position of a value within the given array of sorted values.
|
Example syntax
|
Ordinal({AT1}, {AT1.List}) * 2
Ordinal({EnteredValue}, ["A", "U", "S", "R", "N"]) * 2
Index(DAvg(Ordinal([{AT1}, {AT2}, {AT3}], ['E','D','C','B','A'])), ['E','D','C','B','A'])
|
Example usage/s
|
The first example is used in a calculated assessment item to return a number corresponding to the position of the result in the marking scheme definition for AT1 and multiply it by 2.
This is one way of converting a letter grade into a number out of 10 without having to use a sequence of If statements.
The second example is from the Analyser and operates in a similar fashion to the first example in that it translates a grade in the EnteredValue field into a number. The set of values is explicitly listed because there is no access to marking schemes in formulae in an analysis. Note that it is generally preferable to use the ResultOrdinal field in an analysis to do this.
The third example is the same as that described in the Index function for averaging a series of letter grades, ensuring that they are rounded up when averaged and not down, by listing the values in lowest to highest order.
|
Arguments
|
list is a multi-valued argument containing the possible set of values that can be returned
|
Returns
|
An array
|
Action/Description
|
Allows an array of values to be evaluated for errors, removing any error values from the list of values
|
Example syntax
|
DMax(RemoveError({CalculatedResults}))
|
Example usage/s
|
This function is most likely to be used as part of other calculations, to ensure that errors are excluded. In the example above, where a field may have been created to hold an array of calculated results for a student or a subject from the Aggregate operator, any results that contain errors such as #NUM would be removed prior to the maximum value being extracted by the DMax function.
|
Arguments
|
list is a multi-valued argument containing the possible set of values that can be returned
|
Returns
|
An array
|
Action/Description
|
Removes any values in a list that are not numbers, to produce a an array of numbers
|
Example syntax
|
RemoveNotNumber([45, NA, 73, 89])
DMax(RemoveNotNumber({EnteredValue}))
|
Example usage/s
|
The first example would return an array of [45, 73, 89], ie the NA value would be removed.
This function could be used to filter out any non-numerics prior to performing operations on them. In the second example, being used in an Aggregate operator to, for example, find the maximum result across each subject, any non-numerics would be removed prior to the maximum being identified.
|
Arguments
|
list is a multi-valued argument containing the possible set of values that can be returned
|
Returns
|
An array
|
Action/Description
|
Removes any blank values from an array
|
Example syntax
|
DCount(RemoveBlank({Cl.Roles.Code}))
|
Example usage/s
|
This example is using one of the multi-valued All Roles fields, such as Cl.Roles.Code. A school may have defined several class roles but some roles may be blank, eg where there is only one teacher to a class. The blank roles are being removed, to leave an array of class teacher codes. In this case, a count of the number of teachers per class is being produced by then using DCount.
|
Arguments
|
num is a number representing which item in the list to return
list is a multi-valued argument containing the possible set of values that can be returned
|
Returns
|
Numeric or text string
|
Action/Description
|
Beginning at the end of the list, returns the item in a given array at the location specified
|
Example syntax
|
RevIndex({TASK1}, ["Good", "Better", "Best"])
RevIndex([{AT1}, {AT2}, {AT3}], ['A','B','C','D','E'])
|
Example usage/s
|
The first example allows TASK1 to contain a result between 1 and 3. If the result is 1, the function returns Best; a result of 2 returns Better and 3 returns Good.
The second example could be used to convert a series of numeric scores between 5 and 1 to an A to E score, with A being equal to 5, B to 4, and so on.
This function simply starts at the other end of the list to the Index function and, therefore, is more appropriate to use with an A to E marking scheme than Index().
|
Arguments
|
num is a number representing which item in the list to return
list is a multi-valued argument containing the possible set of values that can be returned
|
Returns
|
Numeric or text string
|
Action/Description
|
Beginning at the end of the list, returns the item in a given array at the location specified. However, any missing items in the list are skipped.
|
Example syntax
|
RevIndexX(2,[{WR1}, {WR2}, {WR3}, {WR4}, {WR5}])
RevIndexX(1,{Cl.Roles.Code})
|
Example usage/s
|
In the first example, where results are stored in the WR1 to WR5 items, the second non-blank result will be returned. For example, if WR5 and WR4 are not missing, WR4 will be returned. If WR4 is missing, WR3 will be returned, if not blank, and so forth.
The second example will return the last non-blank class teacher role and is, therefore, the equivalent of LastX({Cl.Roles.Code}).
|
|