FieldValue - script and chart function
FieldValue() returns the value found in position elem_no of the field field_name (by load order).
Syntax:
FieldValue(field_name , elem_no)
Return data type: dual
Arguments:
Argument | Description |
---|---|
field_name | Name of the field for which the value is required. Must be given as a string value. This means that the field name must be enclosed by single quotes. |
elem_no | The position (element) number of the field, following the load order, that the value is returned for. |
Limitations:
If elem_no is larger than the number of field values, NULL is returned.
First name | Initials |
---|---|
John | JA |
Sue | SB |
Mark | MC |
Peter | PD |
Jane | JE |
Peter | PF |
Examples and results:
The following example uses two fields: First name and Initials.
Examples | Results |
---|---|
Chart function, as measure in a table |
|
FieldValue('First name','1') |
John, because John appears first in the load order of the First name field. Note that in a filter pane John would appear as number 2 from the top, after Jane, as it's sorted alphabetically and not as in the load order. |
FieldValue('First name','7') |
NULL, because there are only 6 values in the First name field. |
Script function, as dimension in a table |
|
Given the table Initials is loaded, as in the sample data: John1: Load FieldValue('First name',1) as MyPos1 Resident Initials; |
MyPos1=John, because 'John' appears first in the load order of the First name field. |
Given the tableInitials is loaded, as in the sample data: Peter1: Load FieldValue('First name',7) as MyPos2 Resident Initials; |
MyPo2s= - (Null), because there are only 6 values in the First namefield. |
Data used in example:
Initials:
LOAD * inline [
"First name"|Initials|"Has cellphone"
John|JA|Yes
Sue|SB|Yes
Mark|MC |No
Peter|PD|No
Jane|JE|Yes
Peter|PF|Yes ] (delimiter is '|');
John1:
Load FieldValue('First name',1) as MyPos1
Resident Initials;
Peter1:
Load FieldValue('First name',7) as MyPos2
Resident Initials;