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. For example, the column in a table. 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. This could correspond to the row in a table, but it depends on the order in which the elements (rows) are loaded.

Limitations:  

If elem_no is larger than the number of field values, NULL is returned.

Examples and results:  

The following examples use the field: First name from the tableNames.

Examples Results

Add the example data to your document and run it.

The table Names is loaded, as in the sample data.

Chart function: In a table containing the dimension First name, add as a measure:

 

FieldValue('First name','1')

John, because John appears first in the load order of the First name field. Note that in a list box 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: Given the table Names is loaded, as in the example data:

 

John1:

Load FieldValue('First name',1) as MyPos1

Resident Names;

MyPos1=John, because 'John' appears first in the load order of the First name field.

Peter1:

Load FieldValue('First name',7) as MyPos2

Resident Names;

MyPo2s= - (Null), because there are only 6 values in the First namefield.

Data used in example:

Names:

LOAD * inline [

"First name"|"Last name"|Initials|"Has cellphone"

John|Anderson|JA|Yes

Sue|Brown|SB|Yes

Mark|Carr|MC |No

Peter|Devonshire|PD|No

Jane|Elliot|JE|Yes

Peter|Franc|PF|Yes ] (delimiter is '|');

John1:

Load FieldValue('First name',1) as MyPos1

Resident Names;

 

Peter1:

Load FieldValue('First name',7) as MyPos2

Resident Names;

Did this information help you?

Thanks for letting us know. Is there anything you'd like to tell us about this topic?

Can you tell us why it did not help you and how we can improve it?